about summary refs log tree commit diff stats
path: root/src/display/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-06 23:24:20 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-06 23:24:20 +0200
commitc15d04041b1b8660000a1517b9d4bfc06f2cb490 (patch)
tree1b51ae72f9589be303f4ed6318cac35309f4dcb2 /src/display/client.nim
parentf94439ca8d5025252e9207cf831ec1e5d0e9a674 (diff)
downloadchawan-c15d04041b1b8660000a1517b9d4bfc06f2cb490.tar.gz
Fix bug in client's unregistered fd handling
+ run JS jobs after every poll in headless mode
Diffstat (limited to 'src/display/client.nim')
-rw-r--r--src/display/client.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/display/client.nim b/src/display/client.nim
index 95f036f8..456ca502 100644
--- a/src/display/client.nim
+++ b/src/display/client.nim
@@ -317,6 +317,8 @@ proc handleError(client: Client, fd: int) =
   elif fd in client.loader.ongoing:
     #TODO something with readablestream?
     discard
+  elif fd in client.loader.unregistered:
+    discard # already unregistered...
   else:
     if fd in client.fdmap:
       let container = client.fdmap[fd]
@@ -329,7 +331,7 @@ proc handleError(client: Client, fd: int) =
     if client.console.container != nil:
       client.console.show()
     else:
-      quit(1)
+      doAssert false
 
 proc inputLoop(client: Client) =
   let selector = client.selector
@@ -352,6 +354,7 @@ proc inputLoop(client: Client) =
         client.runJSJobs()
         client.console.container.requestLines().then(proc() =
           client.console.container.cursorLastLine())
+    client.loader.unregistered.setLen(0)
     if client.pager.scommand != "":
       client.command(client.pager.scommand)
       client.pager.scommand = ""
@@ -379,7 +382,8 @@ proc headlessLoop(client: Client) =
         client.handleError(event.fd)
       if Event.Timer in event.events:
         assert client.timeouts.runTimeoutFd(event.fd)
-        client.runJSJobs()
+    client.runJSJobs()
+    client.loader.unregistered.setLen(0)
     client.acceptBuffers()
 
 proc clientLoadJSModule(ctx: JSContext, module_name: cstring,