I have a nestjs application running on node:18.18.0.
In a function I call await initCrypto();
wrapped in a try catch statement like below:
console.log("first log")
try {
await initCrypto();
} catch (error) {
console.log("error", error)
}
console.log("second log")
const virgilCrypto = new VirgilCrypto();
const accessTokenSigner = new VirgilAccessTokenSigner(virgilCrypto);
const jwtGenerator = new JwtGenerator({
appId: MPStreamIOMessageHandler.__virgilConfig.appId,
apiKeyId: MPStreamIOMessageHandler.__virgilConfig.apiKeyId,
apiKey: virgilCrypto.importPrivateKey(MPStreamIOMessageHandler.__virgilConfig.apiKey),
accessTokenSigner,
millisecondsToLive: 24 * 60 * 60 * 1000, // 1 day alive
});
const virgilJwtToken = jwtGenerator.generateToken(id);
first log
TypeError: Failed to parse URL from /usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/libfoundation.wasm
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at new URL (node:internal/url:637:13)
at new Request (node:internal/deps/undici/undici:7132:25)
at fetch2 (node:internal/deps/undici/undici:10715:25)
at Object.fetch (node:internal/deps/undici/undici:11574:18)
at fetch (node:internal/process/pre_execution:242:25)
at /usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:20314
at /usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:20531
at new <anonymous> (/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:20537)
at Dt (/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:381753) {
input: '/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/libfoundation.wasm',
code: 'ERR_INVALID_URL'
}
}
TypeError: Failed to parse URL from /usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/libfoundation.wasm
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at new URL (node:internal/url:637:13)
at new Request (node:internal/deps/undici/undici:7132:25)
at fetch2 (node:internal/deps/undici/undici:10715:25)
at Object.fetch (node:internal/deps/undici/undici:11574:18)
at fetch (node:internal/process/pre_execution:242:25)
at /usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:20314
at /usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:20531
at new <anonymous> (/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:20537)
at Dt (/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:381753) {
input: '/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/libfoundation.wasm',
code: 'ERR_INVALID_URL'
}
}
/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1
"use strict";var t=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){var r=function(){"undefined"!=typeof document&&document.currentScript&&document.currentScript.src;return function(t){var e;t=t||{},e||(e=void 0!==t?t:{});var r,n={};for(r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);var _,s,c,a,i;_=__dirname+"/",s=function(t){return a||(a=require("fs")),i||(i=require("path")),t=i.normalize(t),a.readFileSync(t,null)},c=function(t){return(t=s(t)).buffer||(t=new Uint8Array(t)),t.buffer||B("Assertion failed: undefined"),t},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",(function(t){throw t})),process.on("unhandledRejection",B),e.inspect=function(){return"[Emscripten Module object]"};var l,o=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(r in n)n.hasOwnProperty(r)&&(e[r]=n[r]);n=null,e.wasmBinary&&(l=e.wasmBinary),"object"!=typeof WebAssembly&&u("no native wasm support detected");var f,d,p,y,h,v,P=new WebAssembly.Table({initial:717,maximum:717,element:"anyfunc"}),x=!1,m="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function g(t,e,r){var n=e+r;for(r=e;t[r]&&!(r>=n);)++r;if(16<r-e&&t.subarray&&m)return m.decode(t.subarray(e,r));for(n="";e<r;){var _=t[e++];if(128&_){var s=63&t[e++];if(192==(224&_))n+=String.fromCharCode((31&_)<<6|s);else{var c=63&t[e++];65536>(_=224==(240&_)?(15&_)<<12|s<<6|c:(7&_)<<18|s<<12|c<<6|63&t[e++])?n+=String.fromCharCode(_):(_-=65536,n+=String.fromCharCode(55296|_>>10,56320|1023&_))}}else n+=String.fromCharCode(_)}return n}function E(t){return 0<t%65536&&(t+=65536-t%65536),t}function N(t){d=t,e.HEAP8=p=new Int8Array(t),e.HEAP16=h=new Int16Array(t),e.HEAP32=v=new Int32Array(t),e.HEAPU8=y=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var I=e.TOTAL_MEMORY||16777216;function b(t){for(;0<t.length;){var r=t.shift();if("function"==typeof r)r();else{var n=r.cu;"number"==typeof n?void 0===r.Ot?e.dynCall_v(n):e.dynCall_vi(n,r.Ot):n(void 0===r.Ot?null:r.Ot)}}}(f=e.wasmMemory?e.wasmMemory:new WebAssembly.Memory({initial:I/65536}))&&(d=f.buffer),I=d.byteLength,N(d),v[39960]=5402880;var w=[],k=[],A=[],C=[];function F(){var t=e.preRun.shift();w.unshift(t)}var T=Math.abs,K=Math.ceil,L=Math.floor,R=Math.min,S=0,z=null;function B(t){throw e.onAbort&&e.onAbort(t),o(t),u(t),x=!0,new WebAssembly.RuntimeError("abort("+t+"). Build with -s ASSERTIONS=1 for more info.")}function Y(){var t=D;return String.prototype.startsWith?t.startsWith("data:application/octet-stream;base64,"):0===t.indexOf("data:application/octet-stream;base64,")}e.preloadedImages={},e.preloadedAudios={};var U,H,D="libfoundation.wasm";if(!Y()){var M=D;D=e.locateFile?e.locateFile(M,_):_+M}function O(t,e){for(var r=0,n=t.length-1;0<=n;n--){var _=t[n];"."===_?t.splice( ...
... AND MORE LOGS WHICH I PUT THEM IN A FILE YOU CAN SEE AT THE END (~400k characters of log) ...
^
RuntimeError: abort(TypeError: Failed to parse URL from /usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/libfoundation.wasm). Build with -s ASSERTIONS=1 for more info.
at process.B (/usr/src/app/node_modules/virgil-crypto/node_modules/@virgilsecurity/core-foundation/node.cjs.js:1:2501)
at process.emit (node:events:517:28)
at emit (node:internal/process/promises:149:20)
at processPromiseRejections (node:internal/process/promises:283:27)
at process.processTicksAndRejections (node:internal/process/task_queues:96:32)
the log above is just a brief slice of the actual log but I attached a file at the end so you can see the complete version of it.
Please give me more understanding about this issue.
why the log is this huge? why it makes the container restart? I don't know why it happens and how I can fix it.
I believe that this is an issue of the virgil-crypto
library and I think that it's OK to pop this huge error log and crash the app.
and appreciate for you library and considerations.