microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.4k stars 28.95k forks source link

debugging cdk application that includes esbuild lambda bundling causes bundling to fail and debugging to terminate #179210

Closed mcacker closed 1 year ago

mcacker commented 1 year ago

Type: Bug

  1. create a CDK project
  2. CDK project includes a lambda which is bundled using esbuild
  3. debug CDK project
  4. application will fail with an error something like below. Note that this occurs whether launching from VSCode or attaching to an independent process. If no debugger is attached to the independent process the CDK application successfully builds.
Debugger attached.
npm ERR! code 1
npm ERR! path /home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-3c480f0dca3238022fb9c3fb1cb820b034e71bc21506dd2639f3e76b04f638ee/node_modules/cpu-features
npm ERR! command failed
npm ERR! command sh -c node buildcheck.js > buildcheck.gypi && node-gyp rebuild
npm ERR! Debugger listening on ws://127.0.0.1:37187/9511d0de-4ddc-4a2a-8e9f-8e94aa56c529
npm ERR! For help, see: https://nodejs.org/en/docs/inspector
npm ERR! Debugger attached.
npm ERR! Waiting for the debugger to disconnect...
npm ERR! Debugger listening on ws://127.0.0.1:43473/3c08ef40-4923-478e-a293-b02df279b8c1
npm ERR! For help, see: https://nodejs.org/en/docs/inspector
npm ERR! Debugger attached.
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.14.2 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "/home/mitchell/anaconda3/bin/python3"
npm ERR! gyp info spawn /home/mitchell/anaconda3/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-3c480f0dca3238022fb9c3fb1cb820b034e71bc21506dd2639f3e76b04f638ee/node_modules/cpu-features/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/mitchell/.cache/node-gyp/16.14.2/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/mitchell/.cache/node-gyp/16.14.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/mitchell/.cache/node-gyp/16.14.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-3c480f0dca3238022fb9c3fb1cb820b034e71bc21506dd2639f3e76b04f638ee/node_modules/cpu-features',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Debugger listening on ws://127.0.0.1:44135/dabf7078-bc81-4786-91f2-1c7e48e0f791
npm ERR! For help, see: https://nodejs.org/en/docs/inspector
npm ERR! Debugger attached.
npm ERR! Waiting for the debugger to disconnect...
npm ERR! gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! stack     at Process.callbackTrampoline (node:internal/async_hooks:130:17)
npm ERR! gyp ERR! System Linux 5.15.0-67-generic
npm ERR! gyp ERR! command "/home/mitchell/.nvm/versions/node/v16.14.2/bin/node" "/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-3c480f0dca3238022fb9c3fb1cb820b034e71bc21506dd2639f3e76b04f638ee/node_modules/cpu-features
npm ERR! gyp ERR! node -v v16.14.2
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok 
npm ERR! Waiting for the debugger to disconnect...

In the above example the independent process was started using the following command:

/usr/bin/env 'NODE_OPTIONS=--require /usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http' \
'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.697619-3fc30f34-128.sock","deferredMode":false,"waitForDebugger":"always","execPath":"/home/mitchell/.nvm/versions/node/v16.14.2/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/tmp/node-debug-callback-bb37c8dd657be1ec"}' \
/home/mitchell/.nvm/versions/node/v16.14.2/bin/node -r ./node_modules/ts-node/register/transpile-only /home/mitchell/.nvm/versions/node/v16.14.2/bin/cdk --profile cdk-fuji \
synth -r arn:aws:iam::xxx:role/cdk-hnb659fds-cfn-exec-role-xxx-us-west-1 --app \"npx\ ts-node\ --prefer-ts-exts\ bin/fuji-cdk-env.ts\" -c config=dev2 \
-c lambdas-project-absolute-path=/home/mitchell/dev/ihs-lambda 

VS Code version: Code 1.77.0 (7f329fe6c66b0f86ae1574c2911b681ad5a45d63, 2023-03-29T10:05:35.165Z) OS version: Linux x64 5.15.0-67-generic Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 1712)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|2, 2, 2| |Memory (System)|31.10GB (10.44GB free)| |Process Argv|--unity-launch --crash-reporter-id fbad975a-66df-4666-b15f-c927c1024594| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|ubuntu| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|ubuntu| |XDG_SESSION_TYPE|x11|
Extensions (33) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|13.3.1 aws-toolkit-vscode|ama|1.67.0 vscode-node-debug-process-picker|apr|1.0.0 vscode-eslint|dba|2.4.0 gitlens|eam|13.4.0 EditorConfig|Edi|0.16.4 vscode-graphql|Gra|0.8.7 vscode-graphql-syntax|Gra|1.1.0 ts-debug|kak|0.0.6 vscode-language-babel|mgm|0.0.38 vscode-docker|ms-|1.24.0 isort|ms-|2022.8.0 python|ms-|2023.6.0 vscode-pylance|ms-|2023.3.40 jupyter|ms-|2023.3.1000892223 jupyter-keymap|ms-|1.1.0 jupyter-renderers|ms-|1.0.15 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-containers|ms-|0.288.0 react-proptypes-intellisense|OfH|1.0.3 vscode-jest|Ort|5.2.3 prisma|Pri|4.12.0 fabric8-analytics|red|0.3.6 java|red|1.16.0 vscode-xml|red|0.24.0 intellicode-api-usage-examples|Vis|0.2.7 vscodeintellicode|Vis|1.2.30 vscode-java-debug|vsc|0.49.1 vscode-java-dependency|vsc|0.21.2 vscode-java-pack|vsc|0.25.10 vscode-java-test|vsc|0.38.2 vscode-maven|vsc|0.41.0
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes516:30244333 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593:30376534 pythonvs932:30410667 cppdebug:30492333 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 nodejswelcome1:30587005 3biah626:30602489 pyind779:30671433 f6dab269:30613381 pythonsymbol12:30671437 showlangstatbar:30672706 vscodedisable:30660115 functionswalk:30687959 pythonms35:30701012 ```
roblourens commented 1 year ago

What is CDK?

/jsDebugLogs

vscodenpa commented 1 year ago

Please collect trace logs using the following instructions:

If you're able to, add "trace": true to your launch.json and reproduce the issue. The location of the log file on your disk will be written to the Debug Console. Share that with us.

⚠️ This log file will not contain source code, but will contain file paths. You can drop it into https://microsoft.github.io/vscode-pwa-analyzer/index.html to see what it contains. If you'd rather not share the log publicly, you can email it to connor@xbox.com

mcacker commented 1 year ago

What is CDK?

/jsDebugLogs

The CDK is the Amazon CDK:

mcacker commented 1 year ago

Here's the output from reproducing the problem with trace on, but I don't know what file you are referring to for the log file:

(base) mitchell@mitchell-Precision-3560:~/dev/fuji-cdk-fresh$  cd /home/mitchell/dev/fuji-cdk-fresh ; /usr/bin/env 'NODE_OPTIONS=--require /usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.813454-c2ee3e2a-37.sock","deferredMode":false,"waitForDebugger":"","execPath":"/home/mitchell/.nvm/versions/node/v16.14.2/bin/node","onlyEntrypoint":false,"verbose":true,"autoAttachMode":"always","fileCallback":"/tmp/node-debug-callback-6fc5fb771381da69"}' /home/mitchell/.nvm/versions/node/v16.14.2/bin/node -r ./node_modules/ts-node/register/transpile-only /home/mitchell/.nvm/versions/node/v16.14.2/bin/cdk --profile cdk-fuji synth -r arn:aws:iam::225996342467:role/cdk-hnb659fds-cfn-exec-role-225996342467-us-west-1 --app \"npx\ ts-node\ --prefer-ts-exts\ bin/fuji-cdk-env.ts\" -c config=dev2 -c lambdas-project-absolute-path=/home/mitchell/dev/ihs-lambda 
runtime.launch Bootloader imported {
  env: {
    inspectorIpc: '/tmp/node-cdp.813454-c2ee3e2a-37.sock',
    deferredMode: false,
    waitForDebugger: '',
    execPath: '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    onlyEntrypoint: false,
    verbose: true,
    autoAttachMode: 'always',
    fileCallback: '/tmp/node-debug-callback-6fc5fb771381da69'
  },
  args: [
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/cdk',
    '--profile',
    'cdk-fuji',
    'synth',
    '-r',
    'arn:aws:iam::225996342467:role/cdk-hnb659fds-cfn-exec-role-225996342467-us-west-1',
    '--app',
    '"npx ts-node --prefer-ts-exts bin/fuji-cdk-env.ts"',
    '-c',
    'config=dev2',
    '-c',
    'lambdas-project-absolute-path=/home/mitchell/dev/ihs-lambda'
  ]
}
runtime Set debug mode { mode: 0 }
Debugger attached.

Other CLIs (PID=866978) are currently reading from cdk.out. Invoke the CLI in sequence, or use '--output' to synth into different directories.
Waiting for the debugger to disconnect...
(base) mitchell@mitchell-Precision-3560:~/dev/fuji-cdk-fresh$  cd /home/mitchell/dev/fuji-cdk-fresh ; /usr/bin/env 'NODE_OPTIONS=--require /usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.813454-8e215128-40.sock","deferredMode":false,"waitForDebugger":"","execPath":"/home/mitchell/.nvm/versions/node/v16.14.2/bin/node","onlyEntrypoint":false,"verbose":true,"autoAttachMode":"always","fileCallback":"/tmp/node-debug-callback-143d6f1dfcc9a9ac"}' /home/mitchell/.nvm/versions/node/v16.14.2/bin/node -r ./node_modules/ts-node/register/transpile-only /home/mitchell/.nvm/versions/node/v16.14.2/bin/cdk --profile cdk-fuji synth -r arn:aws:iam::225996342467:role/cdk-hnb659fds-cfn-exec-role-225996342467-us-west-1 --app \"npx\ ts-node\ --prefer-ts-exts\ bin/fuji-cdk-env.ts\" -c config=dev2 -c lambdas-project-absolute-path=/home/mitchell/dev/ihs-lambda 
runtime.launch Bootloader imported {
  env: {
    inspectorIpc: '/tmp/node-cdp.813454-8e215128-40.sock',
    deferredMode: false,
    waitForDebugger: '',
    execPath: '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    onlyEntrypoint: false,
    verbose: true,
    autoAttachMode: 'always',
    fileCallback: '/tmp/node-debug-callback-143d6f1dfcc9a9ac'
  },
  args: [
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/cdk',
    '--profile',
    'cdk-fuji',
    'synth',
    '-r',
    'arn:aws:iam::225996342467:role/cdk-hnb659fds-cfn-exec-role-225996342467-us-west-1',
    '--app',
    '"npx ts-node --prefer-ts-exts bin/fuji-cdk-env.ts"',
    '-c',
    'config=dev2',
    '-c',
    'lambdas-project-absolute-path=/home/mitchell/dev/ihs-lambda'
  ]
}
runtime Set debug mode { mode: 0 }
Debugger attached.
runtime.launch Bootloader imported {
  env: {
    inspectorIpc: '/tmp/node-cdp.813454-8e215128-40.sock',
    deferredMode: false,
    waitForDebugger: '',
    execPath: '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    onlyEntrypoint: false,
    verbose: true,
    autoAttachMode: 'always',
    openerId: '4efd8621e3812956476a41e7'
  },
  args: [
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/npx',
    'ts-node',
    '--prefer-ts-exts',
    'bin/fuji-cdk-env.ts'
  ]
}
runtime Set debug mode { mode: 0 }
Debugger attached.
runtime.launch Bootloader imported {
  env: {
    inspectorIpc: '/tmp/node-cdp.813454-8e215128-40.sock',
    deferredMode: false,
    waitForDebugger: '',
    execPath: '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    onlyEntrypoint: false,
    verbose: true,
    autoAttachMode: 'always',
    openerId: 'a0e5f4cea12c6bbb3c3b14c9'
  },
  args: [
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    '/home/mitchell/dev/fuji-cdk-fresh/node_modules/.bin/ts-node',
    '--prefer-ts-exts',
    'bin/fuji-cdk-env.ts'
  ]
}
runtime Set debug mode { mode: 0 }
Debugger attached.
config: dev2, account: 225996342467, region: us-west-1
using secretName=${Token[Fn::Join.638]} database credentials..
value for name route53, Graphile is undefined
created graphile cluster
Bundling asset dev2-MPNManagementEnvStack/dev2-MPNManagementEnvpersist-partsFunction/Code/Stage...
runtime.launch Bootloader imported {
  env: {
    inspectorIpc: '/tmp/node-cdp.813454-8e215128-40.sock',
    deferredMode: false,
    waitForDebugger: '',
    execPath: '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    onlyEntrypoint: false,
    verbose: true,
    autoAttachMode: 'always',
    openerId: '9118c19dec66f3e0059bd3c2'
  },
  args: [
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/npx',
    '--no-install',
    'esbuild',
    '--bundle',
    '/home/mitchell/dev/ihs-lambda/src/handlers/persist_parts.ts',
    '--target=node16',
    '--platform=node',
    '--outfile=/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/index.js',
    '--sourcemap',
    '--external:aws-sdk',
    '--external:@prisma/client',
    '--external:prisma',
    '--external:ssh2',
    '--external:cpu-features'
  ]
}
runtime Set debug mode { mode: 0 }
Debugger attached.

  cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/index.js      880.8kb
  cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/index.js.map    1.7mb

⚡ Done in 191ms
Waiting for the debugger to disconnect...
runtime.launch Bootloader imported {
  env: {
    inspectorIpc: '/tmp/node-cdp.813454-8e215128-40.sock',
    deferredMode: false,
    waitForDebugger: '',
    execPath: '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    onlyEntrypoint: false,
    verbose: true,
    autoAttachMode: 'always',
    openerId: '9118c19dec66f3e0059bd3c2'
  },
  args: [
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
    '/home/mitchell/.nvm/versions/node/v16.14.2/bin/npm',
    'ci'
  ]
}
runtime Set debug mode { mode: 0 }
Debugger attached.
npm ERR! code 1
npm ERR! path /home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/node_modules/cpu-features
npm ERR! command failed
npm ERR! command sh -c node buildcheck.js > buildcheck.gypi && node-gyp rebuild
npm ERR! runtime.launch Bootloader imported {
npm ERR!   env: {
npm ERR!     inspectorIpc: '/tmp/node-cdp.813454-8e215128-40.sock',
npm ERR!     deferredMode: false,
npm ERR!     waitForDebugger: '',
npm ERR!     execPath: '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
npm ERR!     onlyEntrypoint: false,
npm ERR!     verbose: true,
npm ERR!     autoAttachMode: 'always',
npm ERR!     openerId: 'fcd128c33a2cba492f6216fa'
npm ERR!   },
npm ERR!   args: [
npm ERR!     '/home/mitchell/.nvm/versions/node/v16.14.2/bin/node',
npm ERR!     '/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
npm ERR!     'rebuild'
npm ERR!   ]
npm ERR! }
npm ERR! runtime Set debug mode { mode: 0 }
npm ERR! Debugger attached.
npm ERR! Waiting for the debugger to disconnect...
npm ERR! Debugger attached.
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.14.2 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "/home/mitchell/anaconda3/bin/python3"
npm ERR! gyp info spawn /home/mitchell/anaconda3/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/node_modules/cpu-features/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/mitchell/.cache/node-gyp/16.14.2/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/mitchell/.cache/node-gyp/16.14.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/mitchell/.cache/node-gyp/16.14.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/node_modules/cpu-features',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Debugger attached.
npm ERR! Waiting for the debugger to disconnect...
npm ERR! gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! stack     at Process.callbackTrampoline (node:internal/async_hooks:130:17)
npm ERR! gyp ERR! System Linux 5.15.0-67-generic
npm ERR! gyp ERR! command "/home/mitchell/.nvm/versions/node/v16.14.2/bin/node" "/home/mitchell/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/node_modules/cpu-features
npm ERR! gyp ERR! node -v v16.14.2
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok 
npm ERR! Waiting for the debugger to disconnect...

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/mitchell/.npm/_logs/2023-04-05T17_28_48_360Z-debug-0.log
Waiting for the debugger to disconnect...
/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2
`),localBundling=options.local?.tryBundle(bundleDir,options),!localBundling){const assetStagingOptions={sourcePath:this.sourcePath,bundleDir,...options};switch(options.bundlingFileAccess){case bundling_1.BundlingFileAccess.VOLUME_COPY:new asset_staging_1.AssetBundlingVolumeCopy(assetStagingOptions).run();break;case bundling_1.BundlingFileAccess.BIND_MOUNT:default:new asset_staging_1.AssetBundlingBindMount(assetStagingOptions).run();break}}}catch(err){const bundleErrorDir=bundleDir+"-error";throw fs.existsSync(bundleErrorDir)&&fs.removeSync(bundleErrorDir),fs.renameSync(bundleDir,bundleErrorDir),new Error(`Failed to bundle asset ${this.node.path}, bundle output is located at ${bundleErrorDir}: ${err}`)}if(fs_1.FileSystem.isEmpty(bundleDir)){const outputDir=localBundling?bundleDir:AssetStaging.BUNDLING_OUTPUT_DIR;throw new Error(`Bundling did not produce any output. Check that content is written to ${outputDir}.`)}}calculateHash(hashType,bundling,outputDir){if(hashType==assets_1.AssetHashType.CUSTOM||hashType==assets_1.AssetHashType.SOURCE&&bundling){const hash=crypto.createHash("sha256");return hash.update(this.customSourceFingerprint??fs_1.FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions)),bundling&&hash.update(JSON.stringify(bundling)),hash.digest("hex")}switch(hashType){case assets_1.AssetHashType.SOURCE:return fs_1.FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions);case assets_1.AssetHashType.BUNDLE:case assets_1.AssetHashType.OUTPUT:if(!outputDir)throw new Error(`Cannot use \`${hashType}\` hash type when \`bundling\` is not specified.`);return fs_1.FileSystem.fingerprint(outputDir,this.fingerprintOptions);default:throw new Error("Unknown asset hash type.")}}}exports.AssetStaging=AssetStaging,_a=JSII_RTTI_SYMBOL_1,AssetStaging[_a]={fqn:"aws-cdk-lib.AssetStaging",version:"2.71.0"},AssetStaging.BUNDLING_INPUT_DIR="/asset-input",AssetStaging.BUNDLING_OUTPUT_DIR="/asset-output",AssetStaging.assetCache=new cache_1.Cache;function renderAssetFilename(assetHash,extension=""){return`asset.${assetHash}${extension}`}function determineHashType(assetHashType,customSourceFingerprint){const hashType=customSourceFingerprint?assetHashType??assets_1.AssetHashType.CUSTOM:assetHashType??assets_1.AssetHashType.SOURCE;if(customSourceFingerprint&&hashType!==assets_1.AssetHashType.CUSTOM)throw new Error(`Cannot specify \`${assetHashType}\` for \`assetHashType\` when \`assetHash\` is specified. Use \`CUSTOM\` or leave \`undefined\`.`);if(hashType===assets_1.AssetHashType.CUSTOM&&!customSourceFingerprint)throw new Error("`assetHash` must be specified when `assetHashType` is set to `AssetHashType.CUSTOM`.");return hashType}function calculateCacheKey(props){return crypto.createHash("sha256").update(JSON.stringify(sortObject(props))).digest("hex")}function sortObject(object){if(typeof object!="object"||object instanceof Array)return object;const ret={};for(const key of Object.keys(object).sort())ret[key]=sortObject(object[key]);return ret}function singleArchiveFile(directory){if(!fs.existsSync(directory))throw new Error(`Directory ${directory} does not exist.`);if(!fs.statSync(directory).isDirectory())throw new Error(`${directory} is not a directory.`);const content=fs.readdirSync(directory);if(content.length===1){const file=path.join(directory,content[0]),extension=getExtension(content[0]).toLowerCase();if(fs.statSync(file).isFile()&&ARCHIVE_EXTENSIONS.includes(extension))return file}}function determineBundledAsset(bundleDir,outputType){const archiveFile=singleArchiveFile(bundleDir);switch(outputType===bundling_1.BundlingOutput.AUTO_DISCOVER&&(outputType=archiveFile?bundling_1.BundlingOutput.ARCHIVED:bundling_1.BundlingOutput.NOT_ARCHIVED),outputType){case bundling_1.BundlingOutput.NOT_ARCHIVED:return{path:bundleDir,packaging:assets_1.FileAssetPackaging.ZIP_DIRECTORY};case bundling_1.BundlingOutput.ARCHIVED:if(!archiveFile)throw new Error("Bundling output directory is expected to include only a single archive file when `output` is set to `ARCHIVED`");return{path:archiveFile,packaging:assets_1.FileAssetPackaging.FILE,extension:getExtension(archiveFile)}}}function getExtension(source){for(const ext of ARCHIVE_EXTENSIONS)if(source.toLowerCase().endsWith(ext))return ext;return path.extname(source)}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ^
Error: Failed to bundle asset dev2-MPNManagementEnvStack/dev2-MPNManagementEnvpersist-partsFunction/Code/Stage, bundle output is located at /home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998-error: Error: bash -c npx --no-install esbuild --bundle "/home/mitchell/dev/ihs-lambda/src/handlers/persist_parts.ts" --target=node16 --platform=node --outfile="/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/index.js" --sourcemap --external:aws-sdk --external:@prisma/client --external:prisma --external:ssh2 --external:cpu-features && cp -R /home/mitchell/dev/ihs-lambda/prisma /home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/ && echo '{"dependencies":{"@prisma/client":"^4.11.0","prisma":"^4.11.0","ssh2":"1.11.0","cpu-features":"0.0.4"}}' > "/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/package.json" && cp "/home/mitchell/dev/fuji-cdk-fresh/package-lock.json" "/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998/package-lock.json" && cd "/home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998" && npm ci && cd /home/mitchell/dev/fuji-cdk-fresh/cdk.out/bundling-temp-7fedfe8e0526cc45c93264e524bd40924eeaed82ac17718b3b2f7c548eb50998 && yarn prisma generate && rm -rf node_modules/@prisma/engines && rm -rf node_modules/.cache run in directory /home/mitchell/dev/fuji-cdk-fresh exited with status 1
    at AssetStaging.bundle (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:603)
    at AssetStaging.stageByBundling (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:4540)
    at stageThisAsset (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:1901)
    at Cache.obtain (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
    at new AssetStaging (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2296)
    at new Asset (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:736)
    at AssetCode.bind (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4628)
    at new Function (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:2829)
    at new NodejsFunction (/home/mitchell/dev/fuji-cdk-fresh/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1171)
    at MPNManagementEnvStack.buildLambda (/home/mitchell/dev/fuji-cdk-fresh/lib/ingestion/mpn-management-env-stack.ts:158:32)
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...

Subprocess exited with error 1
Waiting for the debugger to disconnect...
connor4312 commented 1 year ago

This is an issue in node-gyp and is already fixed in 9.2.0 and onwards (ref)

mcacker commented 1 year ago

This is an issue in node-gyp and is already fixed in 9.2.0 and onwards (ref)

Awesome, thanks. I updated node-gyp (which was only able to be done by updating npm itself (npm install -g npm@latest)), and I could debug without any errors.