Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mniak opened this issue Aug 30, 2024 · 1 comment
Open

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

mniak opened this issue Aug 30, 2024 · 1 comment

Comments

@mniak
Copy link

mniak commented Aug 30, 2024

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)
@AnWeber
Copy link
Owner

AnWeber commented Nov 3, 2024

@mniak The simplest solution is to simply install the dependency yourself. I currently load the file using module.require. But I can't inject my own packages via this API, or I don't know at the moment.
I'll check what options I have, but I'll need time for that as I don't know the API very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants