graphql-engine
graphql-engine copied to clipboard
Running hasura from VSCode terminal with debugger auto-attach behaves erratically
Probably NOT a hasura issue, but interaction with VSCode with debugger auto-attach. Reporting for other users if they run into the same issue.
Version Information
Server Version: CLI Version (for CLI related issue): probably all versions
Tested with a few previous versions 2.12.01, 2.5.0, and 2.1.0 when debugging it.
Environment
OSS
What is the current behaviour?
- Migration files generated from console don't get created (they get created and deleted immediately).
- Metadata commands crash with a message like this
DEBU cannot export actions from metadata: error parsing metadata
object: actions
file: actions.yaml
error: error in converting metadata to sdl: exit status 1: node:internal/modules/package_json_reader:4
const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
^
TypeError: require(...).internalModuleReadJSON is not a function
[...]
What is the expected behaviour?
hasura should work as when ran from the regular terminal.
How to reproduce the issue?
- In VSCode, set
Debugger: Auto-AttachtoAllways - Open the integrated VSCode terminal and verify that the VSCode bootloader require is there
echo $NODE_OPTIONS - run
hasura --log-level=DEBUG metadata diff - you'll get the error and no diff is being displayed
Please provide any traces or logs that could help here.
❯ echo $NODE_OPTIONS
--require "/Users/XXXXXXXXXXXX/Library/Application Support/Code/User/workspaceStorage/6979a91c57285b102086XXXXXXXXXXXX/ms-vscode.js-debug/bootloader.js"
❯ hasura --log-level=DEBUG metadata diff
DEBU global config file exists, verifying contents
DEBU global config is pre-set to &cli.GlobalConfig{UUID:"8c2a8558-7142-47b1-ba8c-XXXXXXXXXXXX", EnableTelemetry:true, ShowUpdateNotification:true, CLIEnvironment:"default"}
DEBU global config: uuid: 8c2a8558-7142-47b1-ba8c-XXXXXXXXXXXX
DEBU global config: enableTelemetry: true
DEBU global config: showUpdateNotification: true
DEBU global config: cliEnvironment: default
DEBU ENV vars read from: /Users/XXXXXXXXXXXX/hasura/.env
DEBU versions: cli: [v2.12.0] server: [v2.7.0]
DEBU compatibility check: [true] cli and server does not match
DEBU cannot get config information from server, this might be because config API is not enabled: error unmarshalling fetching server config
DEBU graphql engine endpoint: http://localhost:8080
DEBU graphql engine admin_secret: ‹×›
DEBU server: uuid: c71e93d7-d8c5-4f55-ad46-XXXXXXXXXXXX
INFO Showing diff between project and server...
DEBU cli-ext: setting up using cli-ext embedded in cli binary
DEBU output: command="sdl to"
DEBU telemetry: beamed fields.time=1.031586375s isError=true
FATA[0002] cannot export actions from metadata: error parsing metadata
object: actions
file: actions.yaml
error: error in converting metadata to sdl: exit status 1: node:internal/modules/package_json_reader:4
const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
^
TypeError: require(...).internalModuleReadJSON is not a function
at internalModuleReadJSON (node:internal/modules/package_json_reader:4:68)
at Object.read (node:internal/modules/package_json_reader:21:42)
at readPackage (node:internal/modules/cjs/loader:292:36)
at readPackageScope (node:internal/modules/cjs/loader:325:19)
at trySelf (node:internal/modules/cjs/loader:440:40)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:918:24)
at Function.Module._load (node:internal/modules/cjs/loader:774:27)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at Module._preloadModules (node:internal/modules/cjs/loader:1261:12)
at loadPreloadModules (node:internal/bootstrap/pre_execution:462:5)
Any possible solutions?
The cause of the issue is that the VSCode sets the NODE_OPTIONS environment variable to require a debugger bootloader which in turn makes the hasura behave erratically.
You (as a user) can either disable the debugger auto-attach, or run hasura with NODE_OPTIONS="" hasura ....
Can you identify the location in the source code where the problem exists?
No.
If the bug is confirmed, would you be willing to submit a PR?
No.
Keywords
vscode, migrations not getting created, metadata crash, internalModuleReadJSON