about summary refs log tree commit diff stats
path: root/src/local/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-14 18:52:32 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-14 18:52:32 +0100
commitc7770d1a56cd65b15004df812de595d8a726c205 (patch)
treef37dcfe32a69b08cd4765272f13be8c3a398a6ee /src/local/client.nim
parent300944c355ce63efacf8f0a686fff8d6dcbb9e2c (diff)
downloadchawan-c7770d1a56cd65b15004df812de595d8a726c205.tar.gz
client: avoid nil defect in flushConsole
Diffstat (limited to 'src/local/client.nim')
-rw-r--r--src/local/client.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/local/client.nim b/src/local/client.nim
index f9b6d9a3..469aff42 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -373,6 +373,11 @@ proc handleRead(client: Client, fd: int) =
     client.pager.handleEvent(container)
 
 proc flushConsole*(client: Client) {.jsfunc.} =
+  if client.console == nil:
+    # hack for when client crashes before console has been initialized
+    client.consoleWrapper = ConsoleWrapper(
+      console: newConsole(newFileStream(stderr))
+    )
   client.handleRead(client.forkserver.estream.fd)
 
 proc handleError(client: Client, fd: int) =