未验证 提交 56ce7805 编写于 作者: A Asher

Prevent process.exit()

上级 567010e1
...@@ -250,13 +250,19 @@ const main = async(): Promise<boolean | void | void[]> => { ...@@ -250,13 +250,19 @@ const main = async(): Promise<boolean | void | void[]> => {
return startCli() || new WrapperProcess().start(); return startCli() || new WrapperProcess().start();
}; };
const exit = process.exit;
process.exit = function (code?: number) {
const err = new Error(`process.exit() was prevented: ${code || "unknown code"}.`);
console.warn(err.stack);
} as (code?: number) => never;
// It's possible that the pipe has closed (for example if you run code-server // It's possible that the pipe has closed (for example if you run code-server
// --version | head -1). Assume that means we're done. // --version | head -1). Assume that means we're done.
if (!process.stdout.isTTY) { if (!process.stdout.isTTY) {
process.stdout.on("error", () => process.exit()); process.stdout.on("error", () => exit());
} }
main().catch((error) => { main().catch((error) => {
logger.error(error.message); logger.error(error.message);
process.exit(typeof error.code === "number" ? error.code : 1); exit(typeof error.code === "number" ? error.code : 1);
}); });
...@@ -653,9 +653,9 @@ export class MainServer extends Server { ...@@ -653,9 +653,9 @@ export class MainServer extends Server {
this._onDidClientConnect.fire({ this._onDidClientConnect.fire({
protocol, onDidClientDisconnect: connection.onClose, protocol, onDidClientDisconnect: connection.onClose,
}); });
// NOTE: We can do this because we only have one connection at a // TODO: Need a way to match clients with a connection. For now
// time but if that changes we need a way to determine which clients // dispose everything which only works because no extensions currently
// belong to a connection and dispose only those. // utilize long-running proxies.
(this.services.get(INodeProxyService) as NodeProxyService)._onUp.fire(); (this.services.get(INodeProxyService) as NodeProxyService)._onUp.fire();
connection.onClose(() => (this.services.get(INodeProxyService) as NodeProxyService)._onDown.fire()); connection.onClose(() => (this.services.get(INodeProxyService) as NodeProxyService)._onDown.fire());
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册