xsnap-worker: define and implement command pipe-related error handling policy and mechanisms #10098
Labels
enhancement
New feature or request
hygiene
Tidying up around the house
needs-design
question
Further information is requested
technical-debt
xsnap
the XS execution tool
A clear and consistent error handling policy has to be developed, documented, and implemented to provide a solid architectural foundation for further development of xsnap-worker and JS that it hosts.
This is a spin-off from #4103 and agoric-labs/xsnap-pub PR#53.
TL;DR:
xsnap-worker's internal state machine is driven by the control loop which reads commands from the parent (controlling process) via one pipe and sends the responses back to the parent via another pipe, all of which implemented in C. JavaScript has no knowledge of the state machine, the pipes, nor the protocol. Thus, the question arises regarding what to do when an error is encountered by a C code while handling command-pipe IO related upcoming JS invocation or the results of there of.
There are two obvious extremes here:
A. On one end of the spectrum there is a strict separation policy which dictates that since JS has no knowledge of the protocol, lacks access to the pipes, and has no agency with respect to establishing or correcting any of the comms-pipe-related issues, the JS side should not get involved with the error handling at all. This implies that any pipe-comms related error leads to an immediate death of the JS container, since C side of the business lacks any understanding of what the actual JS code is doing.
B. Another extreme is to push all of the protocol into JS and let it figure our what to do on a case-by-case basis, depending on specific location in the code and the error type.
Current state of affairs is somewhere in between, but much closer to A above:
In some cases the worker takes a direct exit option xsnap-worker.c:531, while in others attempts to throw an error back into JS world xsnap-worker.c:927. PR#53 attempts to bring it even closer to A by causing and explicit exit on EOF/SIGPIPE.
The text was updated successfully, but these errors were encountered: