AnWeber/vscode-httpyac

Require @grpc/grpc-js fails on httpyac.config.js

mniak opened this issue · 1 comments

I have a server whose certificate name does not match the dns name. So I have been using the following code inside the .http file to skip cert verification:

{{@request
const grpc = require('@grpc/grpc-js');
request.channelCredentials = grpc.ChannelCredentials.createSsl(null, null, null, { 
  checkServerIdentity: () => undefined,
});
}}

But since there are various files, I was trying to move this config to a hook into the httpyac.config.js file. But when requireing '@grpc/grpc-js' there, it complains that the module could not be found. That shouldn't be the case, since the module indeed is already somewhere in order to work during the request.

2024-08-30 11:34:41.802 [error] error in .httpyac.js Cannot find module '@grpc/grpc-js'
Require stack:
- /Users/username/myproj/examples/httpyac.config.js
- /Users/username/myproj/examples/package.json
Error: Cannot find module '@grpc/grpc-js'
Require stack:
- /Users/username/myproj/examples/httpyac.config.js
- /Users/username/myproj/examples/package.json
	at Module._resolveFilename (node:internal/modules/cjs/loader:1152:15)
	at i._resolveFilename (node:electron/js2c/utility_init:2:13405)
	at Module._load (node:internal/modules/cjs/loader:993:27)
	at c._load (node:electron/js2c/node_init:2:13801)
	at E._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:177:6051)
	at i._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:174:31787)
	at o._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:139:34334)
	at Module.require (node:internal/modules/cjs/loader:1240:19)
	at g (/Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js:2:647)
	at configureHooks (/Users/username/myproj/examples/httpyac.config.js:3:22)
	at pJ.configureHooks (/Users/username/.vscode/extensions/anweber.vscode-httpyac-6.15.1/dist/extension.js:177:46549)
	at pJ.initHttpFile (/Users/username/.vscode/extensions/anweber.vscode-httpyac-6.15.1/dist/extension.js:177:46206)
	at async pJ.parse (/Users/username/.vscode/extensions/anweber.vscode-httpyac-6.15.1/dist/extension.js:177:45273)