question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[LIB] LibSquoosh pollutes all error messages in a project

See original GitHub issue

Describe the bug If you have @squoosh/lib imported in your node project in any way, it will inject the contents of index.js:24 into every single error message you get, even errors that don’t have anything to do with Squoosh. This means you now have to scroll through ~800 lines of random text if you want to see anything in your terminal from before the error occurred. This is a huge pain to deal with when you’re developing something and are constantly getting new errors you need to debug.

I have created a minimal test case here, but I have also tested it on a few of my projects, and it happens no matter what, even in errors coming from separate files that don’t have Squoosh imported.

To Reproduce Steps to reproduce the behavior:

  1. Create a new Node project with two files:

package.json

{
    "type": "module",
    "dependencies": {
        "@squoosh/lib": "^0.2.1"
    }
}

test.js

//import { ImagePool } from "@squoosh/lib";

failPolitely();

function failPolitely(){
    throw new Error("Oh noes! I am terribly sorry, but it seems there has been some sort of malfunction.");
}
  1. Install dependencies with npm install

  2. Run the file with node test.js and observe that a normal error message is logged in the console:

file:///[...]/test.js::6
    throw new Error("Oh noes! I am terribly sorry, but it seems there has been some sort of malfunction.");
          ^

Error: Oh noes! I am terribly sorry, but it seems there has been some sort of malfunction.
    at failPolitely (file:////[...]/test.js:6:11)
    at file:////[...]//test.js:3:1
    at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
  1. Uncomment the first line in test.js, so that Squoosh will now be imported when the file runs.

  2. Run the file again with node test.js and observe that the error message is now polluted with some random Squoosh code, even though Squoosh was never used, and the error doesn’t have anything to do with Squoosh:

/[...]/node_modules/@squoosh/lib/build/index.js:24
*/function resize(input_image,input_width,input_height,output_width,output_height,typ_idx,premultiply,color_sp
ace_conversion){var ptr0=passArray8ToWasm0(input_image,wasm.__wbindgen_malloc);var len0=WASM_VECTOR_LEN;wasm.r
esize(8,ptr0,len0,input_width,input_height,output_width,output_height,typ_idx,premultiply,color_space_conversi
on);var r0=getInt32Memory0()[8/4+0];var r1=getInt32Memory0()[8/4+1];var v1=getArrayU8FromWasm0(r0,r1).slice();
wasm.__wbindgen_free(r0,r1*1);return v1}async function load(module,imports){if(typeof Response==="function"&&m
odule instanceof Response){if(typeof WebAssembly.instantiateStreaming==="function"){try{return await WebAssemb
ly.instantiateStreaming(module,imports)}catch(e){if(module.headers.get("Content-Type")!="application/wasm"){co
nsole.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `applicatio
n/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:n",e)}else{throw 
e}}}const bytes=await module.arrayBuffer();return await WebAssembly.instantiate(bytes,imports)}else{const inst
ance=await WebAssembly.instantiate(module,imports);if(instance instanceof WebAssembly.Instance){return{instanc
e,module}}else{return instance}}}async function init(input){if(typeof input==="undefined"){input=(typeof docum
ent==="undefined"?new(require("u"+"rl").URL)("file:"+__filename).href:document.currentScript&&document.current
Script.src||new URL("index.js",document.baseURI).href).replace(/.js$/,"_bg.wasm")}const imports={};if(typeof i
nput==="string"||typeof Request==="function"&&input instanceof Request||typeof URL==="function"&&input instanc
eof URL){input=fetch(input)}const{instance,module}=await load(await input,imports);wasm=instance.exports;init.
__wbindgen_wasm_module=module;return wasm}var resizeWasm=typeof document==="undefined"?new(require("u"+"rl").U
RL)("file:"+__dirname+"/squoosh_resize_bg-74a0d71f.wasm").href:new URL("squoosh_resize_bg-74a0d71f.wasm",docum
ent.currentScript&&document.currentScript.src||document.baseURI).href;var rotateWasm=typeof document==="undefi
ned"?new(require("u"+"rl").URL)("file:"+__dirname+"/rotate-e8fb6784.wasm").href:new URL("rotate-e8fb6784.wasm"
,document.currentScript&&document.currentScript.src||document.baseURI).href;var Module=function(){return funct
ion(Module){Module=Module||{};var e;e||(e=typeof Module!=="undefined"?Module:{});var aa,r;e.ready=new Promise(
function(a,b){aa=a;r=b});var t={},u;for(u in e)e.hasOwnProperty(u)&&(t[u]=e[u]);var v="",ba,ca,da,ea;v=__dirna
me+"/";ba=function(a){da||(da=require("fs"));ea||(ea=require("path"));a=ea.normalize(a);return da.readFileSync
(a,null)};ca=function(a){a=ba(a);a.buffer||(a=new Uint8Array(a));a.buffer||w("Assertion failed: undefined");re
turn a};1<process.argv.length&&process.argv[1].replace(//g,"/");process.argv.slice(2);process.on("uncaughtExce
ption",function(a){throw a});process.on("unhandledRejection",w);e.inspect=function(){return"[Emscripten Module
 object]"};var fa=e.print||console.log.bind(console),y=e.printErr||console.warn.bind(console);for(u in t)t.has
OwnProperty(u)&&(e[u]=t[u]);t=null;var z;e.wasmBinary&&(z=e.wasmBinary);e.noExitRuntime&&e.noExitRuntime;"obje
ct"!==typeof WebAssembly&&w("no native wasm support detected");var A,ha=!1,ia=new TextDecoder("utf8");function
 ja(a,b,c){var d=C;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){va
r l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}if(127>=g){if(b>=c)break;d[b++]=g}else{if(2047>=g){if(b+1>
=c)break;d[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;d[b++]=224|g>>12}else{if(b+3>=c)break;d[b++]=240|g>
>18;d[b++]=128|g>>12&63}d[b++]=128|g>>6&63}d[b++]=128|g&63}}d[b]=0}}var ka=new TextDecoder("utf-16le");functio
n la(a,b){var c=a>>1;for(b=c+b/2;!(c>=b)&&D[c];)++c;return ka.decode(C.subarray(a,c<<1))}function ma(a,b,c){vo
id 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)E[b>>1]=
a.charCodeAt(f),b+=2;E[b>>1]=0;return b-d}function na(a){return 2*a.length}function oa(a,b){for(var c=0,d="";!
(c>=b/4);){var f=F[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1
023)):d+=String.fromCharCode(f)}return d}function pa(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b
;c=d+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65
536+((g&1023)<<10)|l&1023}F[b>>2]=g;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d}function qa(a){for(var b=0,c=0;c<
a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var G,ra,C,E,D,F,I,sa,ta;function ua
(a){G=a;e.HEAP8=ra=new Int8Array(a);e.HEAP16=E=new Int16Array(a);e.HEAP32=F=new Int32Array(a);e.HEAPU8=C=new U
int8Array(a);e.HEAPU16=D=new Uint16Array(a);e.HEAPU32=I=new Uint32Array(a);e.HEAPF32=sa=new Float32Array(a);e.
HEAPF64=ta=new Float64Array(a)}var va=e.INITIAL_MEMORY||16777216;e.wasmMemory?A=e.wasmMemory:A=new WebAssembly
.Memory({initial:va/65536,maximum:32768});A&&(G=A.buffer);va=G.byteLength;ua(G);var J,wa=[],xa=[],ya=[],za=[];
function Aa(){var a=e.preRun.shift();wa.unshift(a)}var K=0,M=null;e.preloadedImages={};e.preloadedAudios={};fu
nction w(a){if(e.onAbort)e.onAbort(a);y(a);ha=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s A
SSERTIONS=1 for more info.");r(a);throw a}function Ca(){var a=N;return String.prototype.startsWith?a.startsWit
h("data:application/octet-stream;base64,"):0===a.indexOf("data:application/octet-stream;base64,")}var N="image
quant_node.wasm";if(!Ca()){var Da=N;N=e.locateFile?e.locateFile(Da,v):v+Da}function Ea(){try{if(z)return new U
int8Array(z);if(ca)return ca(N);throw"both async and sync fetching of the wasm failed"}catch(a){w(a)}}function
 O(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.J;"number"===typeof c?void 0
===b.G?J.get(c)():J.get(c)(b.G):c(void 0===b.G?null:b.G)}}}function Fa(a){switch(a){case 1:return 0;case 2:ret
urn 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Ga=void 0;fun
ction P(a){for(var b="";C[a];)b+=Ga[C[a++]];return b}var Q={},R={},S={};function Ha(a){if(void 0===a)return"_u
nknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}function Ia(a,b){a
=Ha(a);return new Function("body","return function "+a+"() {n    "use strict";    return body.apply(this, argu
ments);n};n")(b)}function Ja(a){var b=Error,c=Ia(a,function(d){this.name=a;this.message=d;d=Error(d).stack;voi
d 0!==d&&(this.stack=this.toString()+"n"+d.replace(/^Error(:[^n]*)?n/,""))});c.prototype=Object.create(b.proto
type);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.na
me+": "+this.message};return c}var Ka=void 0;function T(a){throw new Ka(a)}var La=void 0;function Ma(a,b){func
tion c(h){h=b(h);if(h.length!==d.length)throw new La("Mismatched type converter count");for(var k=0;k<d.length
;++k)U(d[k],h[k])}var d=[];d.forEach(function(h){S[h]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(h,
k){R.hasOwnProperty(h)?f[k]=R[h]:(g.push(h),Q.hasOwnProperty(h)||(Q[h]=[]),Q[h].push(function(){f[k]=R[h];++l;
l===g.length&&c(f)}))});0===g.length&&c(f)}function U(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new Type
Error("registerType registeredInstance requires argPackAdvance");var d=b.name;a||T("type ""+d+"" must have a p
ositive integer typeid pointer");if(R.hasOwnProperty(a)){if(c.K)return;T("Cannot register type '"+d+"' twice")
}R[a]=b;delete S[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}var Pa=[],V=[{},{val
ue:void 0},{value:null},{value:!0},{value:!1}];function Qa(a){4<a&&0===--V[a].H&&(V[a]=void 0,Pa.push(a))}func
tion W(a){switch(a){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var b=Pa.l
ength?Pa.pop():V.length;V[b]={H:1,value:a};return b;}}function Ra(a){return this.fromWireType(I[a>>2])}functio
n Sa(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():"
"+a}function Ta(a,b){switch(b){case 2:return function(c){return this.fromWireType(sa[c>>2])};case 3:return fun
ction(c){return this.fromWireType(ta[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function 
Ua(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+type
of b+" which is not a function");var c=Ia(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;
c=new c;a=b.apply(c,a);return a instanceof Object?a:c}function Va(a){for(;a.length;){var b=a.pop();a.pop()(b)}
}function Wa(a,b){var c=e;if(void 0===c[a].D){var d=c[a];c[a]=function(){c[a].D.hasOwnProperty(arguments.lengt
h)||T("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+
c[a].D+")!");return c[a].D[arguments.length].apply(this,arguments)};c[a].D=[];c[a].D[d.I]=d}}function Xa(a,b,c
){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].D&&void 0!==e[a].D[c])&&T("Cannot register public name '"+a+
"' twice"),Wa(a,a),e.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same numb
er of arguments ("+c+")!"),e[a].D[c]=b):(e[a]=b,void 0!==c&&(e[a].M=c))}function Ya(a,b){for(var c=[],d=0;d<a;
d++)c.push(F[(b>>2)+d]);return c}function Za(a,b){0<=a.indexOf("j")||w("Assertion failed: getDynCaller should 
only be called with i64 sigs");var c=[];return function(){c.length=arguments.length;for(var d=0;d<arguments.le
ngth;d++)c[d]=arguments[d];var f;-1!=a.indexOf("j")?f=c&&c.length?e["dynCall_"+a].apply(null,[b].concat(c)):e[
"dynCall_"+a].call(null,b):f=J.get(b).apply(null,c);return f}}function $a(a,b){a=P(a);var c=-1!=a.indexOf("j")
?Za(a,b):J.get(b);"function"!==typeof c&&T("unknown function pointer with signature "+a+": "+b);return c}var a
b=void 0;function bb(a){a=cb(a);var b=P(a);X(a);return b}function db(a,b){function c(g){f[g]||R[g]||(S[g]?S[g]
.forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new ab(a+": "+d.map(bb).join([", "]))}functi
on eb(a,b,c){switch(b){case 0:return c?function(d){return ra[d]}:function(d){return C[d]};case 1:return c?func
tion(d){return E[d>>1]}:function(d){return D[d>>1]};case 2:return c?function(d){return F[d>>2]}:function(d){re
turn I[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var fb={};function gb(){return"object"
===typeof globalThis?globalThis:Function("return this")()}function hb(a,b){var c=R[a];void 0===c&&T(b+" has un
known type "+bb(a));return c}for(var ib={},jb=[null,[],[]],kb=Array(256),Y=0;256>Y;++Y)kb[Y]=String.fromCharCo
de(Y);Ga=kb;Ka=e.BindingError=Ja("BindingError");La=e.InternalError=Ja("InternalError");e.count_emval_handles=
function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};e.get_first_emval=function(){for(var a=
5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};ab=e.UnboundTypeError=Ja("UnboundTypeError");xa.pus
h({J:function(){lb()}});var nb={o:function(){},p:function(a,b,c,d,f){var g=Fa(c);b=P(b);U(a,{name:b,fromWireTy
pe:function(l){return!!l},toWireType:function(l,h){return h?d:f},argPackAdvance:8,readValueFromPointer:functio
n(l){if(1===c)var h=ra;else if(2===c)h=E;else if(4===c)h=F;else throw new TypeError("Unknown boolean type size
: "+b);return this.fromWireType(h[l>>g])},F:null})},v:function(a,b){b=P(b);U(a,{name:b,fromWireType:function(c
){var d=V[c].value;Qa(c);return d},toWireType:function(c,d){return W(d)},argPackAdvance:8,readValueFromPointer
:Ra,F:null})},n:function(a,b,c){c=Fa(c);b=P(b);U(a,{name:b,fromWireType:function(d){return d},toWireType:funct
ion(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError("Cannot convert ""+Sa(f)+"" to "+thi
s.name);return f},argPackAdvance:8,readValueFromPointer:Ta(b,c),F:null})},e:function(a,b,c,d,f,g){var l=Ya(b,c
);a=P(a);f=$a(d,f);Xa(a,function(){db("Cannot call "+a+" due to unbound types",l)},b-1);Ma(l,function(h){var k
=[h[0],null].concat(h.slice(1)),m=h=a,n=f,p=k.length;2>p&&T("argTypes array size mismatch! Must at least get r
eturn value and 'this' types!");for(var x=null!==k[1]&&!1,B=!1,q=1;q<k.length;++q)if(null!==k[q]&&void 0===k[q
].F){B=!0;break}var Na="void"!==k[0].name,H="",L="";for(q=0;q<p-2;++q)H+=(0!==q?", ":"")+"arg"+q,L+=(0!==q?", 
":"")+"arg"+q+"Wired";m="return function "+Ha(m)+"("+H+") {nif (arguments.length !== "+(p-2)+") {nthrowBinding
Error('function "+m+" called with ' + arguments.length + ' arguments, expected "+(p-2)+" args!');n}n";B&&(m+="
var destructors = [];n");var Oa=B?"destructors":"null";H="throwBindingError invoker fn runDestructors retType 
classParam".split(" ");n=[T,n,g,Va,k[0],k[1]];x&&(m+="var thisWired = classParam.toWireType("+Oa+", this);n");
for(q=0;q<p-2;++q)m+="var arg"+q+"Wired = argType"+q+".toWireType("+Oa+", arg"+q+"); // "+k[q+2].name+"n",H.pu
sh("argType"+q),n.push(k[q+2]);x&&(L="thisWired"+(0<L.length?", ":"")+L);m+=(Na?"var rv = ":"")+"invoker(fn"+(
0<L.length?", ":"")+L+");n";if(B)m+="runDestructors(destructors);n";else for(q=x?1:2;q<k.length;++q)p=1===q?"t
hisWired":"arg"+(q-2)+"Wired",null!==k[q].F&&(m+=p+"_dtor("+p+"); // "+k[q].name+"n",H.push(p+"_dtor"),n.push(
k[q].F));Na&&(m+="var ret = retType.fromWireType(rv);nreturn ret;n");H.push(m+"}n");k=Ua(H).apply(null,n);q=b-
1;if(!e.hasOwnProperty(h))throw new La("Replacing nonexistant public symbol");void 0!==e[h].D&&void 0!==q?e[h]
.D[q]=k:(e[h]=k,e[h].I=q);return[]})},c:function(a,b,c,d,f){function g(m){return m}b=P(b);-1===f&&(f=429496729
5);var l=Fa(c);if(0===d){var h=32-8*c;g=function(m){return m<<h>>>h}}var k=-1!=b.indexOf("unsigned");U(a,{name
:b,fromWireType:g,toWireType:function(m,n){if("number"!==typeof n&&"boolean"!==typeof n)throw new TypeError("C
annot convert ""+Sa(n)+"" to "+this.name);if(n<d||n>f)throw new TypeError("Passing a number ""+Sa(n)+"" from J
S side to C/C++ side to an argument of type ""+b+"", which is outside the valid range ["+d+", "+f+"]!");return
 k?n>>>0:n|0},argPackAdvance:8,readValueFromPointer:eb(b,l,0!==d),F:null})},b:function(a,b,c){function d(g){g>
>=2;var l=I;return new f(G,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Ar
ray,Float32Array,Float64Array][b];c=P(c);U(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{
K:!0})},i:function(a,b){b=P(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(d){var f=I[d>>2];if(c
)for(var g=d+4,l=0;l<=f;++l){var h=d+4+l;if(l==f||0==C[h]){if(g){for(var k=g+(h-g),m=g;!(m>=k)&&C[m];)++m;g=ia
.decode(C.subarray(g,m))}else g="";if(void 0===n)var n=g;else n+=String.fromCharCode(0),n+=g;g=h+1}}else{n=Arr
ay(f);for(l=0;l<f;++l)n[l]=String.fromCharCode(C[d+4+l]);n=n.join("")}X(d);return n},toWireType:function(d,f){
f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instan
ceof Uint8ClampedArray||f instanceof Int8Array||T("Cannot pass non-string to std::string");var l=(c&&g?functio
n(){for(var m=0,n=0;n<f.length;++n){var p=f.charCodeAt(n);55296<=p&&57343>=p&&(p=65536+((p&1023)<<10)|f.charCo
deAt(++n)&1023);127>=p?++m:m=2047>=p?m+2:65535>=p?m+3:m+4}return m}:function(){return f.length})(),h=mb(4+l+1)
;I[h>>2]=l;if(c&&g)ja(f,h+4,l+1);else if(g)for(g=0;g<l;++g){var k=f.charCodeAt(g);255<k&&(X(h),T("String has U
TF-16 code units that do not fit in 8 bits"));C[h+4+g]=k}else for(g=0;g<l;++g)C[h+4+g]=f[g];null!==d&&d.push(X
,h);return h},argPackAdvance:8,readValueFromPointer:Ra,F:function(d){X(d)}})},g:function(a,b,c){c=P(c);if(2===
b){var d=la;var f=ma;var g=na;var l=function(){return D};var h=1}else 4===b&&(d=oa,f=pa,g=qa,l=function(){retu
rn I},h=2);U(a,{name:c,fromWireType:function(k){for(var m=I[k>>2],n=l(),p,x=k+4,B=0;B<=m;++B){var q=k+4+B*b;if
(B==m||0==n[q>>h])x=d(x,q-x),void 0===p?p=x:(p+=String.fromCharCode(0),p+=x),x=q+b}X(k);return p},toWireType:f
unction(k,m){"string"!==typeof m&&T("Cannot pass non-string to C++ string type "+c);var n=g(m),p=mb(4+n+b);I[p
>>2]=n>>h;f(m,p+4,n+b);null!==k&&k.push(X,p);return p},argPackAdvance:8,readValueFromPointer:Ra,F:function(k){
X(k)}})},q:function(a,b){b=P(b);U(a,{L:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:functio
n(){}})},f:Qa,l:function(a){if(0===a)return W(gb());var b=fb[a];a=void 0===b?P(a):b;return W(gb()[a])},j:funct
ion(a){4<a&&(V[a].H+=1)},k:function(a,b,c,d){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=ib
[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var l="return function emval_allocator_"+b+"(co
nstructor, argTypes, args) {n";for(g=0;g<b;++g)l+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(
argTypes >>> 2) + "+g+"], "parameter "+g+"");nvar arg"+g+" = argType"+g+".readValueFromPointer(args);nargs += 
argType"+g+"['argPackAdvance'];n";f=new Function("requireRegisteredType","Module","__emval_register",l+("var o
bj = new constructor("+f+");nreturn __emval_register(obj);n}n"))(hb,e,W);ib[b]=f}return f(a,c,d)},h:function()
{w()},t:function(a,b,c){C.copyWithin(a,b,b+c)},d:function(a){a>>>=0;var b=C.length;if(2147483648<a)return!1;fo
r(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(16777216,a,d);0<d%65536&&(d+=65536-
d%65536);a:{try{A.grow(Math.min(2147483648,d)-G.byteLength+65535>>>16);ua(A.buffer);var f=1;break a}catch(g){}
f=void 0}if(f)return!0}return!1},u:function(){return 0},r:function(){},m:function(a,b,c,d){for(var f=0,g=0;g<c
;g++){for(var l=F[b+8*g>>2],h=F[b+(8*g+4)>>2],k=0;k<h;k++){var m=C[l+k],n=jb[a];if(0===m||10===m){m=1===a?fa:y
;var p;for(p=0;n[p]&&!(NaN<=p);)++p;p=ia.decode(n.subarray?n.subarray(0,p):new Uint8Array(n.slice(0,p)));m(p);
n.length=0}else n.push(m)}f+=h}F[d>>2]=f;return 0},a:A,s:function(){}};(function(){function a(f){e.asm=f.expor
ts;J=e.asm.w;K--;e.monitorRunDependencies&&e.monitorRunDependencies(K);0==K&&M&&(f=M,M=null,f())}function b(f)
{a(f.instance)}function c(f){return Promise.resolve().then(Ea).then(function(g){return WebAssembly.instantiate
(g,d)}).then(f,function(g){y("failed to asynchronously prepare wasm: "+g);w(g)})}var d={a:nb};K++;e.monitorRun
Dependencies&&e.monitorRunDependencies(K);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){retu
rn y("Module.instantiateWasm callback failed with error: "+f),!1}(function(){return z||"function"!==typeof Web
Assembly.instantiateStreaming||Ca()||"function"!==typeof fetch?c(b):fetch(N,{credentials:"same-origin"}).then(
function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){y("wasm streaming compile failed: 
"+g);y("falling back to ArrayBuffer instantiation");return c(b)})})})().catch(r);return{}})();var lb=e.___wasm
_call_ctors=function(){return(lb=e.___wasm_call_ctors=e.asm.x).apply(null,arguments)},mb=e._malloc=function(){
return(mb=e._malloc=e.asm.y).apply(null,arguments)},X=e._free=function(){return(X=e._free=e.asm.z).apply(null,
arguments)},cb=e.___getTypeName=function(){return(cb=e.___getTypeName=e.asm.A).apply(null,arguments)};e.___emb
ind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.B)
.apply(null,arguments)};e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.C).apply(null,arguments)};var Z;
M=function ob(){Z||pb();Z||(M=ob)};function pb(){function a(){if(!Z&&(Z=!0,e.calledRun=!0,!ha)){O(xa);O(ya);aa
(e);if(e.onRuntimeInitialized)e.onRuntimeInitialized();if(e.postRun)for("function"==typeof e.postRun&&(e.postR
un=[e.postRun]);e.postRun.length;){var b=e.postRun.shift();za.unshift(b)}O(za)}}if(!(0<K)){if(e.preRun)for("fu
nction"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)Aa();O(wa);0<K||(e.setStatus?(e.setStatus("Ru
nning..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}e.run=pb;if(e.preIni
t)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();pb();return 
Module.ready}}();var imageQuantWasm=typeof document==="undefined"?new(require("u"+"rl").URL)("file:"+__dirname
+"/imagequant_node-a308c591.wasm").href:new URL("imagequant_node-a308c591.wasm",document.currentScript&&docume
nt.currentScript.src||document.baseURI).href;class ImageData$1{constructor(data,width,height){this.data=data;t
his.width=width;this.height=height}}const pngEncDecPromise=init$2(fs.promises.readFile(pathify(pngEncDecWasm))
);const oxipngPromise=init$1(fs.promises.readFile(pathify(oxipngWasm)));const resizePromise=init(fs.promises.r
eadFile(pathify(resizeWasm)));const imageQuantPromise=instantiateEmscriptenWasm(Module,imageQuantWasm);globalT
his.ImageData=ImageData$1;function resizeNameToIndex(name){switch(name){case"triangle":return 0;case"catrom":r
eturn 1;case"mitchell":return 2;case"lanczos3":return 3;default:throw Error(`Unknown resize algorithm "${name}
"`);}}function resizeWithAspect({input_width,input_height,target_width,target_height}){if(!target_width&&!targ
et_height){throw Error("Need to specify at least width or height when resizing")}if(target_width&&target_heigh
t){return{width:target_width,height:target_height}}if(!target_width){return{width:Math.round(input_width/input
_height*target_height),height:target_height}}if(!target_height){return{width:target_width,height:Math.round(in
put_height/input_width*target_width)}}}const preprocessors={resize:{name:"Resize",description:"Resize the imag
e before compressing",instantiate:async()=>{await resizePromise;return(buffer,input_width,input_height,{width,
height,method,premultiply,linearRGB})=>{({width,height}=resizeWithAspect({input_width,input_height,target_widt
h:width,target_height:height}));return new ImageData$1(resize(buffer,input_width,input_height,width,height,res
izeNameToIndex(method),premultiply,linearRGB),width,height)}},defaultOptions:{method:"lanczos3",fitMethod:"str
etch",premultiply:true,linearRGB:true}},// // TODO: Need to handle SVGs and HQX                                                                                                                                                            
                                                                                                                                                                
                                                                                                                                                                
                                                                                                                                                                
                                                                                                                                                                
                                                                                                                                                                
                                                            

Error: Oh noes! I am terribly sorry, but it seems there has been some sort of malfunction.
    
at failPolitely (file:///[...]/test.js:6:11)
    at file:////[...]//test.js:3:1
    at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
  1. Observe how annoying it was to scroll down and find this last point 😉

Expected behavior The error message from step 5 should be identical to the one from step 3.

Version:

  • OS w/ version: Like Ubuntu 20.10
  • Node version: 12.22.1, 14.17.0, 16.1.0
  • npm version: 6.14.12, 7.11.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
surmacommented, May 24, 2021

Will have to wait until #1027 lands or we’ll end up in conflict hell 😄

0reactions
atjncommented, Jun 16, 2021

Thanks! I’ve been using a locally build package this past week 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emscripten glue code injects itself into unrelated errors #14270
In Node, the glue code seems to inject itself into throws somehow, ... [LIB] LibSquoosh pollutes all error messages in a project ......
Read more >
Introducing libSquoosh - web.dev
We are happy to introduce libSquoosh, an experimental Node library on top of which the Squoosh CLI is built, giving you all the...
Read more >
How to debug knex.js Without having to pollute my db
You can build a knex query, but until anycodings_knex.js you attach a .then() or awiat() (or run anycodings_knex.js . asCallback((error ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found