LIPS-scheme / lips

Scheme based powerful lisp interpreter in JavaScript
https://lips.js.org
Other
414 stars 34 forks source link

Promise without resolve ends Node.js process #337

Closed jcubic closed 6 months ago

jcubic commented 6 months ago

Example:

(new Promise (lambda (resolve) 10))

This terminates the LIPS process instantly. Web REPL works fine, it pauses the terminal.

jcubic commented 6 months ago

A mystery:

(define resolve #t)
(new Promise (lambda (res) 10)) ;; exits immedietly
(new Promise (lambda (res) (set! resolve res))) ;; exits immedietly
(new Promise (lambda (res) (setTimeout (lambda ()) 5000))) ;; exits after 5 seconds

This can't be Garbage Collector.

jcubic commented 6 months ago

Found the problem on Stack Overflow: Node exits without error and doesn't await promise (Event callback).

The same code exits in Node.js if you create a file, I was testing in REPL.

await new Promise(() => 10).then(() => {})
console.log('Not executed');

or even:

await new Promise(() => {});
console.log('Not executed');