Skip to content

Commit

Permalink
💩 [Debug] Get details about segmentation faults using the `segfault-h…
Browse files Browse the repository at this point in the history
…andler` package
  • Loading branch information
sounisi5011 committed Jul 3, 2023
1 parent 26d7361 commit f133d91
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"command-join": "^3.0.0",
"cross-spawn": "^7.0.2",
"mri": "^1.2.0",
"segfault-handler": "1.3.0",
"which-pm": "^2.0.0",
"which-pm-runs": "^1.1.0"
},
Expand Down
24 changes: 24 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// ///// ↓DEBUG↓ /////
import path from 'node:path';
import url from 'node:url';

// ///// ↑DEBUG↑ /////
import { execFileAsync, isObject } from '../utils.js';
import { getPackageManagerData } from './detect-package-manager.js';

Expand All @@ -22,6 +27,14 @@ async function tryNpmConfigGet(key: string): Promise<string | null> {
// This allows npm commands to be used even in projects with non-npm package managers defined.
// see https://github.com/nodejs/corepack/tree/v0.14.0#environment-variables
COREPACK_ENABLE_STRICT: '0',
// ///// ↓DEBUG↓ /////
NODE_OPTIONS:
`${process.env['NODE_OPTIONS'] ?? ''} ` +
`--require "${path.resolve(
url.fileURLToPath(import.meta.url),
'../segfault-handler.cjs',
)}"`,
// ///// ↑DEBUG↑ /////
},
})
.then(({ stdout }) => stdout.replace(/\n$/, ''))
Expand Down
4 changes: 4 additions & 0 deletions src/utils/segfault-handler.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import path from 'path';
import SegfaultHandler from 'segfault-handler';

SegfaultHandler.registerHandler(path.join(process.cwd(), 'crash.log'));

0 comments on commit f133d91

Please sign in to comment.