Skip to content

Writing to sdtin crashes sketch #29

Open
@chpio

Description

@chpio

Hi,

i need to run code in nodejs. So my idea was to spawn a nodejs process and communicate with it by sending jsonl messages to stdin (you call it sdtin) & getting jsonl messages back from stdout.

But when i attempt to write to stdin it just crashes sketch. No crash reports in console.

const child = spawn(
	path.resolve(process.cwd(), "./Contents/Sketch/external"),
	[],
	{cwd: path.resolve(process.cwd(), "./Contents/Sketch")},
);

// @ts-ignore
const stdin: Writable = child.stdin || child.sdtin;

const buf = Buffer.from(JSON.stringify({type: "getImages"}) + "\n");
console.log("buf", buf);

await new Promise<void>((onOk, onErr) => {
	// crashes here
	stdin.write(buf, (err) => {
		if (err !== null && err !== undefined) {
			onErr(err);
		} else {
			onOk();
		}
	});
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions