mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
refactor(AWS Local Invocation): Rely on observable spawn
It's to better debug observed issues
This commit is contained in:
parent
6cbc83aff0
commit
6d9749699d
@ -605,28 +605,25 @@ class AwsInvokeLocal {
|
||||
|
||||
const wrapperPath = await this.resolveRuntimeWrapperPath('invoke.py');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const python = spawn(runtime.split('.')[0], ['-u', wrapperPath, handlerPath, handlerName], {
|
||||
env: process.env,
|
||||
});
|
||||
return new Promise((resolve) => {
|
||||
const python = spawnExt(
|
||||
runtime.split('.')[0],
|
||||
['-u', wrapperPath, handlerPath, handlerName],
|
||||
{
|
||||
env: process.env,
|
||||
}
|
||||
);
|
||||
python.stdout.on('data', (buf) => {
|
||||
writeText(buf.toString());
|
||||
});
|
||||
python.stderr.on('data', (buf) => {
|
||||
writeText(buf.toString());
|
||||
});
|
||||
python.on('close', () => resolve());
|
||||
let isRejected = false;
|
||||
python.on('error', (error) => {
|
||||
isRejected = true;
|
||||
reject(error);
|
||||
});
|
||||
|
||||
process.nextTick(() => {
|
||||
if (isRejected) return; // Runtime not available
|
||||
python.stdin.write(input);
|
||||
python.stdin.end();
|
||||
});
|
||||
python.child.stdin.write(input);
|
||||
python.child.stdin.end();
|
||||
|
||||
resolve(python);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user