async_hooks fails obscurely when double initialized
mhofman opened this issue · 0 comments
mhofman commented
Describe the bug
SES has double init checks to produce clear errors when trying to lockdown the environment twice. However it seems that when async_hooks taming is involved through @endo/init
, the error becomes a lot more obscure.
Steps to reproduce
package.json
:
{
"type": "module",
"dependencies": {
"@endo/init": "^1.1.7",
"endo-old-init": "npm:@endo/init@1.1.4"
}
}
foo.js
:
import "endo-old-init/debug.js";
import "@endo/init/debug.js";
console.log("done");
Expected behavior
SES_ALREADY_LOCKED_DOWN
error
Platform environment
@endo/init: 1.1.7
Additional context
Originally discovered by running yarn test:fast-usdc
in https://github.com/Agoric/agoric-sdk/tree/bce5b917edace606af3cd468927b51f97fea5a51/multichain-testing
Screenshots
SES_UNCAUGHT_EXCEPTION: (TypeError#1)
TypeError#1: Cannot redefine property: Symbol(async_id_symbol)
at InertConstructor.defineProperty (<anonymous>)
at setup (file:///home/node/workspace/agoric/tmp/repro-endo-double-init/node_modules/@endo/init/src/node-async_hooks.js:216:10)
at file:///home/node/workspace/agoric/tmp/repro-endo-double-init/node_modules/@endo/init/src/node-async_hooks-patch.js:4:1
at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:106:12)
Additionally the InertConstructor.defineProperty
is confusing, but orthogonal.