-
Notifications
You must be signed in to change notification settings - Fork 797
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('gcloud') causing forge to crash #362
Comments
The issue occurs specifically in /js/forge.js
|
bump |
1 similar comment
bump |
We hope to get this fixed per #357 (comment). |
The patch from #445 was released in 0.6.46 since it hopefully won't cause other problems. But I was unable to reproduce the issue with basic require tests. Can someone please post a test case that fails? If not, can someone use console.log or similar and report what non-function data is causing the failure? It would be good to fix the cause of this problem rather than depend on the hack to fix it. |
Thanks for merging and the quick release! Steps to reproduce;
If you are using Visual Studio Code, you can use this launch.json for a matching debugging environment;
I have done some quick debugging. Jest is wrapping require to check if mocking is required. This wrapped require is being called at line 31 See also this Jest issue report; jestjs/jest#1946 |
@mdebruijne have you been able to get this working with Jest yet? I've become stuck on it as well. |
@gschier The latest forge release fixed the simple jest + node-forge test case shown above. Is there some other simple test case that also fails? |
Yes, this has been fixed, everything is working as expected now. There are two things you should check;
|
@davidlehn @mdebruijne thanks for the responses. I'm using forge directly (not through Here's what I mean. const forge = require('node-forge')();
console.log(forge.random); // > undefined
console.log(forge.util); // > undefined
// the list goes on ... All of the root-level functions (that I'm using) seem to work fine though. Any insight as to why this might be happening? I can try putting together a simple test project tonight or tomorrow if that will help. |
The difference in your case vs the google-cloud case is that you are actually using this code path from node-forge. The google-cloud package only use node-forge for a tool to convert PKCS12/P12 to PKCS1/PEM. This is a one time operation and therefore isn't something that you normally use in code and needs to be unit tested. The require statements in forge.js are still empty objects so the underlying problem hasn't been fixed at all. The only thing the pull request does is prevent crashes for applications that don't use this specific code path. If your application needs this code path then it is still broken. |
For those who want a test case, mkdir a dir and:
Add a const forge = require('node-forge');
require('jest');
describe('forge', () => {
it('forge', () => {expect(forge).toBeDefined()})
it('forge.random', () => {expect(forge.random).toBeDefined()})
it('forge.util', () => {expect(forge.util).toBeDefined()})
});
Yeah, it's failing. I just a bit ago I added another attempt at converting forge to CommonJS style. Testing with that work-in-progress and the above test works fine. So this will fix itself at some point after that cjs branch or similar gets merged and released. |
@davidlehn that PR looks awesome! So excited for that. |
Should be addressed in a new release now that #456 has been merged. |
That's great news! 👏 |
My app suddenly started crashing and I've narrowed it down to a require('gcloud') on a server controller. This happened after merging from another branch. I've looked and looked, tried deleting and reinstalling all node_modules and nothing has helped. There are no differences between the package.json files on either branch. I am using Node version 5.0.0 and I have tried using gcloud 0.24.0, 0.25.1 and 0.28.0.
app/services/node_modules/node-forge/js/forge.js:41 mods[i](forge);
TypeError: mods[i] is not a function at Object.module.exports (/Users/myhome/Development/app/services/node_modules/node-forge/js/forge.js:41:14) at defineFunc (/Users/myhome/Development/app/services/node_modules/node-forge/js/forge.js:47:10) at Object.<anonymous> (/Users/myhome/Development/app/services/node_modules/node-forge/js/forge.js:90:14) at global.define (/Users/myhome/Development/app/services/node_modules/amd-loader/amd-loader.js:79:28) at define (/Users/myhome/Development/app/services/node_modules/node-forge/js/forge.js:57:17) at /Users/myhome/Development/app/services/node_modules/node-forge/js/forge.js:59:1 at Object.<anonymous> (/Users/myhome/Development/app/services/node_modules/node-forge/js/forge.js:92:3) at Module._compile (module.js:425:26) at Module.module.constructor._compile (/Users/myhome/Development/app/services/node_modules/amd-loader/amd-loader.js:10:31) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (/Users/myhome/Development/app/services/node_modules/google-p12-pem/index.js:1:75) at Module._compile (module.js:425:26) at Module.module.constructor._compile (/Users/myhome/Development/app/services/node_modules/amd-loader/amd-loader.js:10:31) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (/Users/myhome/Development/app/services/node_modules/gtoken/lib/index.js:1:77) at Module._compile (module.js:425:26) at Module.module.constructor._compile (/Users/myhome/Development/app/services/node_modules/amd-loader/amd-loader.js:10:31) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (/Users/myhome/Development/app/services/node_modules/google-auth-library/lib/auth/jwtclient.js:20:14) at Module._compile (module.js:425:26) at Module.module.constructor._compile (/Users/myhome/Development/app/services/node_modules/amd-loader/amd-loader.js:10:31) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (/Users/myhome/Development/app/services/node_modules/google-auth-library/lib/auth/googleauth.js:19:17) at Module._compile (module.js:425:26) at Module.module.constructor._compile (/Users/myhome/Development/app/services/node_modules/amd-loader/amd-loader.js:10:31) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17)
The text was updated successfully, but these errors were encountered: