Closed ochicf closed 1 year ago
@ochicf is attempting to deploy a commit to the Rico Kahler Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
sanity-codegen-dev | 🔄 Building (Inspect) | May 10, 2023 2:29pm |
This MR attempts to improve how child process exits are handled.
Problems I encountered and solved by this fix:
process.exit(0)
caused that the caller process never receive the message sent withprocess!.send(...)
, even when sucessful (not sure why this happens). Just settingprocess.exitCode
and letting the process to end normally worked wellNotes:
loadAndExecute().then(...)
callback to handle the success case. This way:loadAndExecute
function returns the schema, and the parsing is done in the success handler.on
calls with promises, similar to how it was done previously with the only listener used. Wrapping all of them withPromise.race
will yield the first one to be resolved, being:on('message')
: if success or error is handledon('error')
: if error is not handled in the child processon('close')
: if process has ended by any other reason. This is just a fallback as it would be expected for the other listeners to be triggered first