Turn on --enable-source-maps

Turn on source map deduction in stack traces from thrown errors. This
feature is off by default due to potential performance degration in
certain corner cases.  For the dev environment add instructions for
passing the option to node.
This commit is contained in:
Hornwitser committed 2023-11-24 20:53:16 +01:00
1 parent 142cf8a626
commit 6eda1f78d5
2 files changed
+15 -3

No files matched your search

+2
View File
@@ -72,6 +72,8 @@ The documentation uses the binaries provided by the packages, but for the develo
npx clusteriohost -> node packages/host
npx clusterioctl -> node packages/ctl
By default node does not enable source maps, to get stack traces pointing to the `.ts` files you will need to pass `--enable-source-maps` to `node` or set the environment variable `NODE_OPTIONS=--enable-source-maps`.
Note that to use `clusterioctl` you will have to create a control config first:
node packages/controller bootstrap create-ctl-config [admin-user]
+13 -3
View File
@@ -375,17 +375,26 @@ async function writeScripts(mode) {
if (process.platform === "win32") {
await safeOutputFile(
"run-controller.cmd",
"@echo off\n.\\node_modules\\.bin\\clusteriocontroller.cmd run\n"
`\
@echo off.
set "NODE_OPTIONS=--enable-source-maps %NODE_OPTIONS%"
\\node_modules\\.bin\\clusteriocontroller.cmd run
`
);
} else {
await safeOutputFile(
"run-controller.sh",
"#!/bin/sh\nexec ./node_modules/.bin/clusteriocontroller run\n",
`\
#!/bin/sh
export "NODE_OPTIONS=--enable-source-maps $NODE_OPTIONS"
exec ./node_modules/.bin/clusteriocontroller run
`,
{ mode: 0o755 },
);
await safeOutputFile(
"systemd/clusteriocontroller.service",
`[Unit]
`\
[Unit]
Description=Clusterio Controller
[Service]
@@ -394,6 +403,7 @@ Group=${await groupIdToName(os.userInfo().gid)}
WorkingDirectory=${process.cwd()}
KillMode=mixed
KillSignal=SIGINT
Environment=NODE_OPTIONS=--enable-source-maps
ExecStart=${process.cwd()}/node_modules/.bin/clusteriocontroller run --log-level=warn
[Install]