serve-handler | The foundation of serve | Web Framework library
kandi X-RAY | serve-handler Summary
kandi X-RAY | serve-handler Summary
The foundation of `serve`
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of serve-handler
serve-handler Key Features
serve-handler Examples and Code Snippets
Community Discussions
Trending Discussions on serve-handler
QUESTION
We latelly encountered a problem on our project while trying to make a subprocess pipe a whole base64 encoded picture (around 355K) to it's parent process : but pictures seemed randomly truncated and we still don't get this behaviour nor found a solution.
We found a workaround to transmit these pictures with tempfile based communication, but we still wanna understand the problem about these inter-process communication limitations.
Here is the closest minimum and reproductible example we succeeded to produce that highlights this behaviour, we have a python script that tries to retrieve the data from a node subprocess that generates the data to retrieve. But the length of data the parent process is able to get seems limited in a nondeterministic way.
This example tests the equality between the requested data length and the actual retrieved length.
- test.py :
ANSWER
Answered 2020-Jan-15 at 18:33The problem is in your JavaScript code and you can find the explanation here :
Calling
process.exit()
will force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations toprocess.stdout
andprocess.stderr
.
and :
In most situations, it is not actually necessary to call
process.exit()
explicitly. The Node.js process will exit on its own if there is no additional work pending in the event loop. Theprocess.exitCode
property can be set to tell the process which exit code to use when the process exits gracefully.
You are calling process.exit()
before the call to process.stdout.write()
has completed (writing to pipes is asynchronous on POSIX). This causes the JS process to exit prematurely, and interrupts the writing before all the data has been written.
If you want to set the error code, you should set process.exitCode = errorCode
as you do and allow the event loop to end gracefully without calling process.exit()
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serve-handler
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page