server: do not crash on xdg-open failure

Summary:
Previously, clicking a file could crash the isl-server process like:

  open file /home/quark/tmp/erepos/rs/isl/y.txt
  node:events:491
        throw er; // Unhandled 'error' event
        ^

  Error: spawn xdg-open ENOENT
      at ChildProcess._handle.onexit (node:internal/child_process:283:19)
      at onErrorNT (node:internal/child_process:476:16)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
  Emitted 'error' event on ChildProcess instance at:
      at ChildProcess._handle.onexit (node:internal/child_process:289:12)
      at onErrorNT (node:internal/child_process:476:16)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawn xdg-open',
    path: 'xdg-open',
    spawnargs: [ '/home/quark/tmp/erepos/rs/isl/y.txt' ]
  }

  Node.js v18.16.0

Fix it by not letting the error propagate to the top-level handler.

Reviewed By: zzl0

Differential Revision: D45800641

fbshipit-source-id: 0f028f71d20c29dafd8395bc12ec23a937264224
This commit is contained in:
Jun Wu 2023-05-15 16:12:48 -07:00 committed by Facebook GitHub Bot
parent c5eb6448c9
commit 93e3939e72

View File

@ -82,6 +82,10 @@ export const browserServerPlatform: ServerPlatform = {
windowsHide: false,
windowsVerbatimArguments: true,
});
// Silent error. Don't crash the server process.
proc.on('error', err => {
repo?.logger.log('failed to open', path, err);
});
proc.unref();
}
break;