@dom96 asked me to create a small sample illustrating the issue.
https://github.com/sergiotapia/async-check
The code runs well on Linux and Windows, the echos in the {.async} function are seen as expected.
On Mac, we see no echos, despite Jester serving responses.
nim -v
Nim Compiler Version 1.2.2 [MacOSX: amd64]
Compiled at 2020-06-25
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
I hope this is just an error in my code, but if it's a Nim bug I'm sure you guys will be able to tackle it. I love Nim so far!
Reproduced this with Nim 1.2.2 on macOS 10.15.5.
Tried to reproduce with latest devel, but got a compile error in Jester. Is that library not compatible?
/Users/snej/.nimble/pkgs/jester-0.4.3/jester.nim(704, 26) Error: undeclared identifier: 'initInterval'
@snej you need jester devel for nim devel :) initInterval -> initDuration (due to removed deprecated stuff from stdlib)
Looks like the main thread is blocked in joinThread, which is blocked in pthread_join, and not running any async tasks. Via the sample tool:
Call graph:
1851 Thread_419617 DispatchQueue_1: com.apple.main-thread (serial)
+ 1851 start (in libdyld.dylib) + 1 [0x7fff71ee3cc9]
+ 1851 main (in async_test) + 62 [0x10c36cc8e]
+ 1851 NimMain (in async_test) + 42 [0x10c36cc4a]
+ 1851 NimMainInner (in async_test) + 9 [0x10c36c9b9]
+ 1851 NimMainModule (in async_test) + 590 [0x10c36cc0e]
+ 1851 serve__uyVGO9b8GZDPA7YPHmJyO1w (in async_test) + 1557 [0x10c363115]
+ 1851 run__UlykqHUJzrYfskoCKJB7AQ (in async_test) + 1043 [0x10c354a93]
+ 1851 joinThreads__khVjhz9bVAEzWbLJTwAvaVA (in async_test) + 158 [0x10c2f2f7e]
+ 1851 joinThread__b7SXibO9bv1Wvu9ani9anuO5gsystem (in async_test) + 32 [0x10c2f2fc0]
+ 1851 _pthread_join (in libsystem_pthread.dylib) + 347 [0x7fff720e95c2]
+ 1851 __ulock_wait (in libsystem_kernel.dylib) + 10 [0x7fff7202655e]
Ooh, thanks for trying this out @snej. I didn't get a chance to yet.
My guess from looking at this though is that this may be a httpbeast bug. Can you try compiling with -d:useStdlib?
If I use -d:useStdlib would that avoid using httpbeast? We're trying to determine if the bug is in that application?
@sergiotapia yes, it'll avoid using httpbeast. dom96 is trying to determine if it's a nim async bug, jester bug or httpbeast bug
Trying now.
@dom96 @Yardanico @snej
Using this in my nim.cfg, the applications works fine on Mac now.
-d:ssl
-d:useStdlib
--threads:on
@dom96 What should I do here? Does this mean I can't ship my app with it using httpbeast until the bug is fixed in that project?
Yep. What kind of app is this?
You can make your config conditional like so:
-d:ssl
--threads:on
@if macosx:
# pending bug #15019
-d:useStdlib
@end
Thanks @Araq and @dom96
This is a small app that is meant to always be running on your machine, and regularly crawl html websites and rss feeds, and import records into a sqlite database. A self-hosted torrent search engine.
Most helpful comment
You can make your config conditional like so: