wonderful-bird-78843
05/02/2022, 11:03 PMimport { promisify } from "util";
import { execFile as execFileReal } from 'child_process';
const execFile = promisify(execFileReal);
and then in a sns Topic.onEvent()
I'm doing:
try {
const { stdout } = await execFile('curl', args);
console.log("stdout:", stdout);
msg.Response = stdout;
}
On up
, I'm getting:
Diagnostics:
pulumi:pulumi:Stack (mcurl-typescript-mcurl):
error: Error serializing '(ev, ctx) => __awaiter(this, void 0, ...': index.ts(137,57)
'(ev, ctx) => __awaiter(this, void 0, ...': index.ts(137,57): captured
'execFile', a function defined at
'(...args) => { const { promise, reso ...': node:child_process(231,9): which captured
'orig', a function defined at
function 'execFile': node:child_process(278,17): which captured
'ArrayIsArray', a function defined at
function 'isArray': which could not be serialized because
it was a native code function.
wonderful-bird-78843
05/02/2022, 11:05 PMwonderful-bird-78843
05/02/2022, 11:06 PMchild_process
should just be serialized into an import on the server, no?
For the reasons cited previously, modules are captured in a special but intuitive fashion. When a module is captured in code, it is translated into an idiomatic require call in the serialized JavaScript code.
wonderful-bird-78843
05/02/2022, 11:07 PMThis form of module capturing only applies to external modules that are referenced, such as modules that are directly part of Node, or are in the node_modules directory.
wonderful-bird-78843
05/02/2022, 11:07 PMwonderful-bird-78843
05/02/2022, 11:09 PMconst execFile = promisify(execFileReal);
into the callback, and that fixed itwonderful-bird-78843
05/02/2022, 11:09 PM