Set maximum buffer size fixes #1135

This commit is contained in:
Amir Raminfar
2021-04-09 14:24:42 -07:00
parent 013aefa969
commit ed80bff954
2 changed files with 4 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ export default {
methods: {
loadLogs(id) {
this.reset();
this.es = new EventSource(`${config.base}/api/logs/stream?id=${this.id}`);
this.es = new EventSource(`${config.base}/api/logs/stream?id=${id}`);
this.es.addEventListener("container-stopped", (e) => {
this.es.close();
this.buffer.push({ event: "container-stopped", message: "Container stopped", date: new Date() });

View File

@@ -100,6 +100,9 @@ func (h *handler) streamLogs(w http.ResponseWriter, r *http.Request) {
defer reader.Close()
scanner := bufio.NewScanner(reader)
const maxCapacity = 1024 * 1024
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
for scanner.Scan() {
message := scanner.Text()
fmt.Fprintf(w, "data: %s\n", message)