bridgetownrb / node-runner

A simple way to execute Javascript in a Ruby context via Node
MIT License
32 stars 4 forks source link

Why in node-runer js there is no catch in promise? #5

Open aspirisen opened 5 months ago

aspirisen commented 5 months ago

Here https://github.com/bridgetownrb/node-runner/blob/master/lib/node_runner.js#L3

image

We have wrapper try-catch block. But is there any specific reason why Promise.resolve() doesn't have catch clause?

jaredcwhite commented 5 months ago

@aspirisen Honestly not sure! What should happen in a catch clause here? 🤔

aspirisen commented 5 months ago

@jaredcwhite I think it should have same stdout log

process.stdout.write(JSON.stringify(['err', '' + err, err.stack]))

Because func call is not awaited then try catch block doesn't handle the error

image

With await

image

With catch clause

image