Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc npm: rename shutdown method to close and add muteStdErr option to mute the stderr output #5588

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions deltachat-rpc-server/npm-package/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ export function getRPCServerPath(


export type DeltaChatOverJsonRpcServer = StdioDeltaChat & {
shutdown: () => Promise<void>;
readonly pathToServerBinary: string;
};

export interface StartOptions {
/** whether to disable outputting stderr to the parent process's stderr */
muteStdErr: boolean;
}

/**
*
* @param directory directory for accounts folder
* @param options
*/
export function startDeltaChat(directory: string, options?: Partial<SearchOptions> ): Promise<DeltaChatOverJsonRpcServer>
export function startDeltaChat(directory: string, options?: Partial<SearchOptions & StartOptions> ): Promise<DeltaChatOverJsonRpcServer>


export namespace FnTypes {
Expand Down
5 changes: 2 additions & 3 deletions deltachat-rpc-server/npm-package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export async function startDeltaChat(directory, options) {
RUST_LOG: process.env.RUST_LOG || "info",
DC_ACCOUNTS_PATH: directory,
},
stdio: ["pipe", "pipe", options.muteStdErr ? "ignore" : "inherit"],
});

server.on("error", (err) => {
Expand All @@ -144,13 +145,11 @@ export async function startDeltaChat(directory, options) {
throw new Error("Server quit");
});

server.stderr.pipe(process.stderr);

/** @type {import('./index').DeltaChatOverJsonRpcServer} */
//@ts-expect-error
const dc = new StdioDeltaChat(server.stdin, server.stdout, true);

dc.shutdown = async () => {
dc.close = () => {
shouldClose = true;
if (!server.kill()) {
console.log("server termination failed");
Expand Down