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

Uncaught TypeError: Failed to resolve module specifier "env". Relative references must start with either "/", "./", or "../". #2215

Closed
chinedufn opened this issue Jun 22, 2020 · 11 comments
Labels

Comments

@chinedufn
Copy link
Contributor

chinedufn commented Jun 22, 2020

Describe the Bug

When I build and deploy my application from my dev machine (macos) everything works fine.

When I build and deploy from CI (self hosted GH action running ubuntu 18.04) I'm seeing the following error in my browser's console.

Uncaught TypeError: Failed to resolve module specifier "env". Relative references must start with either "/", "./", or "../".

I see this as the first line line my generated wasm-bindgen JS file

import * as __wbg_star0 from 'env';

And then closer to the bottom of the file:

imports['env'] = __wbg_star0;

Both my dev machine and CI run the exact same commands to generate and deploy the build.

Additional Context

# Dev machine (mac)
$ rustc -V
rustc 1.45.0-nightly (5fd2f06e9 2020-05-31)
# CI machine (linux)
$ rustc -V
rustc 1.45.0-nightly (74e804683 2020-05-30)

wasm-bindgen = 0.2.63

Click to view full generated JS FILE import * as __wbg_star0 from 'env';

let wasm;

const heap = new Array(32).fill(undefined);

heap.push(undefined, null, true, false);

function getObject(idx) { return heap[idx]; }

let heap_next = heap.length;

function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}

function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}

function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];

heap[idx] = obj;
return idx;

}

function isLikeNone(x) {
return x === undefined || x === null;
}

let cachegetFloat64Memory0 = null;
function getFloat64Memory0() {
if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) {
cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer);
}
return cachegetFloat64Memory0;
}

let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory0;
}

function debugString(val) {
// primitive types
const type = typeof val;
if (type == 'number' || type == 'boolean' || val == null) {
return ${val};
}
if (type == 'string') {
return "${val}";
}
if (type == 'symbol') {
const description = val.description;
if (description == null) {
return 'Symbol';
} else {
return Symbol(${description});
}
}
if (type == 'function') {
const name = val.name;
if (typeof name == 'string' && name.length > 0) {
return Function(${name});
} else {
return 'Function';
}
}
// objects
if (Array.isArray(val)) {
const length = val.length;
let debug = '[';
if (length > 0) {
debug += debugString(val[0]);
}
for(let i = 1; i < length; i++) {
debug += ', ' + debugString(val[i]);
}
debug += ']';
return debug;
}
// Test for built-in
const builtInMatches = /[object ([^\]]+)]/.exec(toString.call(val));
let className;
if (builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
return toString.call(val);
}
if (className == 'Object') {
// we're a user defined class or Object
// JSON.stringify avoids problems with cycles, and is generally much
// easier than looping through ownProperties of val.
try {
return 'Object(' + JSON.stringify(val) + ')';
} catch (_) {
return 'Object';
}
}
// errors
if (val instanceof Error) {
return ${val.name}: ${val.message}\n${val.stack};
}
// TODO we could test for more things here, like Sets and Maps.
return className;
}

let WASM_VECTOR_LEN = 0;

let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory0;
}

let cachedTextEncoder = new TextEncoder('utf-8');

const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});

function passStringToWasm0(arg, malloc, realloc) {

if (realloc === undefined) {
    const buf = cachedTextEncoder.encode(arg);
    const ptr = malloc(buf.length);
    getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
    WASM_VECTOR_LEN = buf.length;
    return ptr;
}

let len = arg.length;
let ptr = malloc(len);

const mem = getUint8Memory0();

let offset = 0;

for (; offset < len; offset++) {
    const code = arg.charCodeAt(offset);
    if (code > 0x7F) break;
    mem[ptr + offset] = code;
}

if (offset !== len) {
    if (offset !== 0) {
        arg = arg.slice(offset);
    }
    ptr = realloc(ptr, len, len = offset + arg.length * 3);
    const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
    const ret = encodeString(arg, view);

    offset += ret.written;
}

WASM_VECTOR_LEN = offset;
return ptr;

}

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });

cachedTextDecoder.decode();

function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}

function makeMutClosure(arg0, arg1, dtor, f) {
const state = { a: arg0, b: arg1, cnt: 1 };
const real = (...args) => {
// First up with a closure we increment the internal reference
// count. This ensures that the Rust closure environment won't
// be deallocated while we're invoking it.
state.cnt++;
const a = state.a;
state.a = 0;
try {
return f(a, state.b, ...args);
} finally {
if (--state.cnt === 0) wasm.__wbindgen_export_2.get(dtor)(a, state.b);
else state.a = a;
}
};
real.original = state;
return real;
}

function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1);
getUint8Memory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function __wbg_adapter_26(arg0, arg1, arg2) {
var ptr0 = passArray8ToWasm0(arg2, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.wasm_bindgen__convert__closures__invoke1_mut__hd9999804164ec548(arg0, arg1, ptr0, len0);
}

function __wbg_adapter_29(arg0, arg1, arg2) {
wasm.wasm_bindgen__convert__closures__invoke1_mut__h01ff3aa2e73417f9(arg0, arg1, addHeapObject(arg2));
}

function __wbg_adapter_32(arg0, arg1, arg2) {
wasm.wasm_bindgen__convert__closures__invoke1_mut__h01ff3aa2e73417f9(arg0, arg1, addHeapObject(arg2));
}

function __wbg_adapter_35(arg0, arg1, arg2) {
wasm.wasm_bindgen__convert__closures__invoke1_mut__h01ff3aa2e73417f9(arg0, arg1, addHeapObject(arg2));
}

function __wbg_adapter_38(arg0, arg1) {
wasm.wasm_bindgen__convert__closures__invoke0_mut__ha0c1211a4fd86bd9(arg0, arg1);
}

function __wbg_adapter_41(arg0, arg1, arg2) {
wasm.wasm_bindgen__convert__closures__invoke1_mut__h01ff3aa2e73417f9(arg0, arg1, addHeapObject(arg2));
}

function handleError(f) {
return function () {
try {
return f.apply(this, arguments);

    } catch (e) {
        wasm.__wbindgen_exn_store(addHeapObject(e));
    }
};

}

function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}

let cachegetFloat32Memory0 = null;
function getFloat32Memory0() {
if (cachegetFloat32Memory0 === null || cachegetFloat32Memory0.buffer !== wasm.memory.buffer) {
cachegetFloat32Memory0 = new Float32Array(wasm.memory.buffer);
}
return cachegetFloat32Memory0;
}

function getArrayF32FromWasm0(ptr, len) {
return getFloat32Memory0().subarray(ptr / 4, ptr / 4 + len);
}
/**

  • We expose our WebClient to the JS initialization function that happens in our index.html.

  • It essentially calls ::new() and .start()
    */
    export class WebClient {

    static __wrap(ptr) {
    const obj = Object.create(WebClient.prototype);
    obj.ptr = ptr;

      return obj;
    

    }

    free() {
    const ptr = this.ptr;
    this.ptr = 0;

      wasm.__wbg_webclient_free(ptr);
    

    }
    /**

    • Create a new instance of the WebClient.
    • This typically happens once.
    • TODO: Pass in the canvas' id instead of hard coding it so that we can embed the
    • web client on any site should we want to (i.e. I could embed it into the dev journals).
      /
      constructor() {
      var ret = wasm.webclient_new();
      return WebClient.__wrap(ret);
      }
      /
      *
    • Start the WebClient.
    • It will run in a request animation loop and render to the canvas once per tick.
      */
      start() {
      wasm.webclient_start(this.ptr);
      }
      }

async function load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {

    if (typeof WebAssembly.instantiateStreaming === 'function') {
        try {
            return await WebAssembly.instantiateStreaming(module, imports);

        } catch (e) {
            if (module.headers.get('Content-Type') != 'application/wasm') {
                console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/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 instance = await WebAssembly.instantiate(module, imports);

    if (instance instanceof WebAssembly.Instance) {
        return { instance, module };

    } else {
        return instance;
    }
}

}

async function init(input) {
if (typeof input === 'undefined') {
input = import.meta.url.replace(/.js$/, '_bg.wasm');
}
const imports = {};
imports.wbg = {};
imports.wbg.__wbindgen_cb_drop = function(arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
var ret = false;
return ret;
};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_Window_d64060d13377409b = function(arg0) {
var ret = getObject(arg0) instanceof Window;
return ret;
};
imports.wbg.__wbg_requestAnimationFrame_96f88ce2d311332e = handleError(function(arg0, arg1) {
var ret = getObject(arg0).requestAnimationFrame(getObject(arg1));
return ret;
});
imports.wbg.__wbg_document_bcf9d67bc56e8c6d = function(arg0) {
var ret = getObject(arg0).document;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_body_6209a4fe12ca8a07 = function(arg0) {
var ret = getObject(arg0).body;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_getElementById_0e0dd6444cdc0602 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_HtmlCanvasElement_308a7fa689ff20ef = function(arg0) {
var ret = getObject(arg0) instanceof HTMLCanvasElement;
return ret;
};
imports.wbg.__wbg_createElement_467bb064d2ae5833 = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).createElement(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
});
imports.wbg.__wbg_setid_7699062cf7a220be = function(arg0, arg1, arg2) {
getObject(arg0).id = getStringFromWasm0(arg1, arg2);
};
imports.wbg.__wbg_appendChild_11200a24a11d9886 = handleError(function(arg0, arg1) {
var ret = getObject(arg0).appendChild(getObject(arg1));
return addHeapObject(ret);
});
imports.wbg.__wbg_performance_d78dfb23cb3aa2b5 = function(arg0) {
var ret = getObject(arg0).performance;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_now_1a2bf048df058d4a = function(arg0) {
var ret = getObject(arg0).now();
return ret;
};
imports.wbg.__wbg_getContext_554fc171434d411b = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).getContext(getStringFromWasm0(arg1, arg2));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
});
imports.wbg.__wbg_instanceof_WebGlRenderingContext_dca65729c7187d57 = function(arg0) {
var ret = getObject(arg0) instanceof WebGLRenderingContext;
return ret;
};
imports.wbg.__wbg_getParameter_732430a798f2b462 = handleError(function(arg0, arg1) {
var ret = getObject(arg0).getParameter(arg1 >>> 0);
return addHeapObject(ret);
});
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = typeof(obj) === 'number' ? obj : undefined;
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
};
imports.wbg.__wbg_location_c5898e25a8ee2172 = function(arg0) {
var ret = getObject(arg0).location;
return addHeapObject(ret);
};
imports.wbg.__wbg_search_475a1fc8c7af6e1c = handleError(function(arg0, arg1) {
var ret = getObject(arg1).search;
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
});
imports.wbg.__wbg_newwithstr_bb3474d1e9122853 = handleError(function(arg0, arg1) {
var ret = new URLSearchParams(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
});
imports.wbg.__wbg_get_284a4fb9dde419d6 = function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg1).get(getStringFromWasm0(arg2, arg3));
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbg_history_82b6dc62ebba92cf = handleError(function(arg0) {
var ret = getObject(arg0).history;
return addHeapObject(ret);
});
imports.wbg.__wbg_new_f46e6afe0b8a862e = function() {
var ret = new Object();
return addHeapObject(ret);
};
imports.wbg.__wbg_title_23dea888c29354ce = function(arg0, arg1) {
var ret = getObject(arg1).title;
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbg_replaceState_5d439950cefc03be = handleError(function(arg0, arg1, arg2, arg3, arg4, arg5) {
getObject(arg0).replaceState(getObject(arg1), getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5));
});
imports.wbg.__wbg_getExtension_899678856c287080 = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).getExtension(getStringFromWasm0(arg1, arg2));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
});
imports.wbg.__wbg_createBuffer_501da6aef1c4b91c = function(arg0) {
var ret = getObject(arg0).createBuffer();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_addEventListener_fe52a115589ccc2c = handleError(function(arg0, arg1, arg2, arg3) {
getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
});
imports.wbg.__wbindgen_cb_forget = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbg_new_59cb74e423758ede = function() {
var ret = new Error();
return addHeapObject(ret);
};
imports.wbg.__wbg_stack_558ba5917b466edd = function(arg0, arg1) {
var ret = getObject(arg1).stack;
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) {
try {
console.error(getStringFromWasm0(arg0, arg1));
} finally {
wasm.__wbindgen_free(arg0, arg1);
}
};
imports.wbg.__wbg_self_944d201f31e01c91 = handleError(function() {
var ret = self.self;
return addHeapObject(ret);
});
imports.wbg.__wbg_window_993fd51731b86960 = handleError(function() {
var ret = window.window;
return addHeapObject(ret);
});
imports.wbg.__wbg_globalThis_8379563d70fab135 = handleError(function() {
var ret = globalThis.globalThis;
return addHeapObject(ret);
});
imports.wbg.__wbg_global_073eb4249a3a8c12 = handleError(function() {
var ret = global.global;
return addHeapObject(ret);
});
imports.wbg.__wbindgen_is_undefined = function(arg0) {
var ret = getObject(arg0) === undefined;
return ret;
};
imports.wbg.__wbg_newnoargs_bfddd41728ab0b9c = function(arg0, arg1) {
var ret = new Function(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_call_20c04382b27a4486 = handleError(function(arg0, arg1) {
var ret = getObject(arg0).call(getObject(arg1));
return addHeapObject(ret);
});
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
var ret = debugString(getObject(arg1));
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbg_self_1b7a39e3a92c949c = handleError(function() {
var ret = self.self;
return addHeapObject(ret);
});
imports.wbg.__wbg_require_604837428532a733 = function(arg0, arg1) {
var ret = require(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_crypto_968f1772287e2df0 = function(arg0) {
var ret = getObject(arg0).crypto;
return addHeapObject(ret);
};
imports.wbg.__wbg_getRandomValues_a3d34b4fee3c2869 = function(arg0) {
var ret = getObject(arg0).getRandomValues;
return addHeapObject(ret);
};
imports.wbg.__wbg_getRandomValues_f5e14ab7ac8e995d = function(arg0, arg1, arg2) {
getObject(arg0).getRandomValues(getArrayU8FromWasm0(arg1, arg2));
};
imports.wbg.__wbg_randomFillSync_d5bd2d655fdf256a = function(arg0, arg1, arg2) {
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
};
imports.wbg.__wbg_createTexture_77f1141b79fa578d = function(arg0) {
var ret = getObject(arg0).createTexture();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_activeTexture_a4d9c550dcacf795 = function(arg0, arg1) {
getObject(arg0).activeTexture(arg1 >>> 0);
};
imports.wbg.__wbg_bindTexture_998c063ed7315afd = function(arg0, arg1, arg2) {
getObject(arg0).bindTexture(arg1 >>> 0, getObject(arg2));
};
imports.wbg.__wbg_texParameteri_d819847181bb4c5a = function(arg0, arg1, arg2, arg3) {
getObject(arg0).texParameteri(arg1 >>> 0, arg2 >>> 0, arg3);
};
imports.wbg.__wbg_pixelStorei_bec30af179b630a6 = function(arg0, arg1, arg2) {
getObject(arg0).pixelStorei(arg1 >>> 0, arg2);
};
imports.wbg.__wbg_texImage2D_3441b124d44b5416 = handleError(function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
getObject(arg0).texImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10));
});
imports.wbg.__wbg_generateMipmap_be29f942c5711bbe = function(arg0, arg1) {
getObject(arg0).generateMipmap(arg1 >>> 0);
};
imports.wbg.__wbg_bindBuffer_c96c99b259d952f4 = function(arg0, arg1, arg2) {
getObject(arg0).bindBuffer(arg1 >>> 0, getObject(arg2));
};
imports.wbg.__wbg_getAttribLocation_659ded06867c4ae1 = function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg0).getAttribLocation(getObject(arg1), getStringFromWasm0(arg2, arg3));
return ret;
};
imports.wbg.__wbg_vertexAttribPointer_5660aa1f2b819de1 = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
getObject(arg0).vertexAttribPointer(arg1 >>> 0, arg2, arg3 >>> 0, arg4 !== 0, arg5, arg6);
};
imports.wbg.__wbg_enableVertexAttribArray_0f8b0b1592940e3f = function(arg0, arg1) {
getObject(arg0).enableVertexAttribArray(arg1 >>> 0);
};
imports.wbg.__wbg_vertexAttribDivisorANGLE_5685bbed4d0917f7 = function(arg0, arg1, arg2) {
getObject(arg0).vertexAttribDivisorANGLE(arg1 >>> 0, arg2 >>> 0);
};
imports.wbg.__wbg_bindVertexArrayOES_b909c084b9b2adff = function(arg0, arg1) {
getObject(arg0).bindVertexArrayOES(getObject(arg1));
};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
var ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbg_get_fa38f22e54fe1ab1 = handleError(function(arg0, arg1) {
var ret = Reflect.get(getObject(arg0), getObject(arg1));
return addHeapObject(ret);
});
imports.wbg.__wbg_new_a938277eeb06668d = function() {
var ret = new Array();
return addHeapObject(ret);
};
imports.wbg.__wbg_apply_d867294d9cfb22c5 = handleError(function(arg0, arg1, arg2) {
var ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2));
return addHeapObject(ret);
});
imports.wbg.__wbg_texSubImage2D_cfa75026c4393fb0 = handleError(function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {
getObject(arg0).texSubImage2D(arg1 >>> 0, arg2, arg3, arg4, arg5, arg6, arg7 >>> 0, arg8 >>> 0, arg9 === 0 ? undefined : getArrayU8FromWasm0(arg9, arg10));
});
imports.wbg.__wbg_createFramebuffer_01c472dd3eee0c68 = function(arg0) {
var ret = getObject(arg0).createFramebuffer();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_bindFramebuffer_d583fcb30e94f137 = function(arg0, arg1, arg2) {
getObject(arg0).bindFramebuffer(arg1 >>> 0, getObject(arg2));
};
imports.wbg.__wbg_framebufferTexture2D_848ce644c8fa502d = function(arg0, arg1, arg2, arg3, arg4, arg5) {
getObject(arg0).framebufferTexture2D(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4), arg5);
};
imports.wbg.__wbg_createRenderbuffer_34bc571791e437e1 = function(arg0) {
var ret = getObject(arg0).createRenderbuffer();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_bindRenderbuffer_23b966789a70623f = function(arg0, arg1, arg2) {
getObject(arg0).bindRenderbuffer(arg1 >>> 0, getObject(arg2));
};
imports.wbg.__wbg_renderbufferStorage_f0f9bf3c958e1ad0 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).renderbufferStorage(arg1 >>> 0, arg2 >>> 0, arg3, arg4);
};
imports.wbg.__wbg_framebufferRenderbuffer_cad4c8d9c455567b = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).framebufferRenderbuffer(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, getObject(arg4));
};
imports.wbg.__wbg_enable_9449adf5ab2510e3 = function(arg0, arg1) {
getObject(arg0).enable(arg1 >>> 0);
};
imports.wbg.__wbg_viewport_18c9d4ac8f2880ac = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).viewport(arg1, arg2, arg3, arg4);
};
imports.wbg.__wbg_clearColor_b9e0f7e215dc534e = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).clearColor(arg1, arg2, arg3, arg4);
};
imports.wbg.__wbg_clear_ec5c1c21ed3b2fe2 = function(arg0, arg1) {
getObject(arg0).clear(arg1 >>> 0);
};
imports.wbg.__wbg_useProgram_c4a6df84383cd1a6 = function(arg0, arg1) {
getObject(arg0).useProgram(getObject(arg1));
};
imports.wbg.__wbg_drawElements_ede2468147fdc77f = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).drawElements(arg1 >>> 0, arg2, arg3 >>> 0, arg4);
};
imports.wbg.__wbg_blendFuncSeparate_d734831848c198a9 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).blendFuncSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0);
};
imports.wbg.__wbindgen_memory = function() {
var ret = wasm.memory;
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_Memory_56d1581563190159 = function(arg0) {
var ret = getObject(arg0) instanceof WebAssembly.Memory;
return ret;
};
imports.wbg.__wbg_buffer_985803c87989344b = function(arg0) {
var ret = getObject(arg0).buffer;
return addHeapObject(ret);
};
imports.wbg.__wbg_new_75cd19a33bebb54e = function(arg0) {
var ret = new Float32Array(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_subarray_8ef12d7b4db8f774 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_bufferData_e135b678b6ef2433 = function(arg0, arg1, arg2, arg3) {
getObject(arg0).bufferData(arg1 >>> 0, getObject(arg2), arg3 >>> 0);
};
imports.wbg.__wbg_drawArraysInstancedANGLE_c0ca554ec8609848 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).drawArraysInstancedANGLE(arg1 >>> 0, arg2, arg3, arg4);
};
imports.wbg.__wbg_disable_53e208e5c1646215 = function(arg0, arg1) {
getObject(arg0).disable(arg1 >>> 0);
};
imports.wbg.__wbg_readPixels_08a875a194dd79da = handleError(function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
getObject(arg0).readPixels(arg1, arg2, arg3, arg4, arg5 >>> 0, arg6 >>> 0, arg7 === 0 ? undefined : getArrayU8FromWasm0(arg7, arg8));
});
imports.wbg.__wbg_createVertexArrayOES_c7b781c1ecee6607 = function(arg0) {
var ret = getObject(arg0).createVertexArrayOES();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_newwithbyteoffsetandlength_3c83a6445776097f = function(arg0, arg1, arg2) {
var ret = new Float32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_newwithbyteoffsetandlength_36d42f1c91e7259d = function(arg0, arg1, arg2) {
var ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_newwithbyteoffsetandlength_c8bb08455573d4e5 = function(arg0, arg1, arg2) {
var ret = new Uint16Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_createProgram_531dab3c15c28e4f = function(arg0) {
var ret = getObject(arg0).createProgram();
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_attachShader_9958cc9636fc8494 = function(arg0, arg1, arg2) {
getObject(arg0).attachShader(getObject(arg1), getObject(arg2));
};
imports.wbg.__wbg_linkProgram_9e60adcb42d34c3c = function(arg0, arg1) {
getObject(arg0).linkProgram(getObject(arg1));
};
imports.wbg.__wbg_getProgramParameter_c021157c5817259f = function(arg0, arg1, arg2) {
var ret = getObject(arg0).getProgramParameter(getObject(arg1), arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_boolean_get = function(arg0) {
const v = getObject(arg0);
var ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
return ret;
};
imports.wbg.__wbg_getProgramInfoLog_5def5bb3d8d30e1f = function(arg0, arg1, arg2) {
var ret = getObject(arg1).getProgramInfoLog(getObject(arg2));
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbg_createShader_376b269548a48c7a = function(arg0, arg1) {
var ret = getObject(arg0).createShader(arg1 >>> 0);
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_shaderSource_c208cc7a688e8923 = function(arg0, arg1, arg2, arg3) {
getObject(arg0).shaderSource(getObject(arg1), getStringFromWasm0(arg2, arg3));
};
imports.wbg.__wbg_compileShader_82966bc7f1d070fe = function(arg0, arg1) {
getObject(arg0).compileShader(getObject(arg1));
};
imports.wbg.__wbg_getShaderParameter_d03718a8c98a4d23 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).getShaderParameter(getObject(arg1), arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_getShaderInfoLog_b619769ff40aac70 = function(arg0, arg1, arg2) {
var ret = getObject(arg1).getShaderInfoLog(getObject(arg2));
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbg_uniform4fv_4cad84f8c8f25fef = function(arg0, arg1, arg2, arg3) {
getObject(arg0).uniform4fv(getObject(arg1), getArrayF32FromWasm0(arg2, arg3));
};
imports.wbg.__wbg_getUniformLocation_d3462c180fd1b8c4 = function(arg0, arg1, arg2, arg3) {
var ret = getObject(arg0).getUniformLocation(getObject(arg1), getStringFromWasm0(arg2, arg3));
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_uniform1i_491fc975f3e97a42 = function(arg0, arg1, arg2) {
getObject(arg0).uniform1i(getObject(arg1), arg2);
};
imports.wbg.__wbg_uniformMatrix4fv_fdf943cdc3c4a3d4 = function(arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).uniformMatrix4fv(getObject(arg1), arg2 !== 0, getArrayF32FromWasm0(arg3, arg4));
};
imports.wbg.__wbg_uniform3fv_ea8847c03339cab4 = function(arg0, arg1, arg2, arg3) {
getObject(arg0).uniform3fv(getObject(arg1), getArrayF32FromWasm0(arg2, arg3));
};
imports.wbg.__wbg_uniform1f_c730f5bf75b95845 = function(arg0, arg1, arg2) {
getObject(arg0).uniform1f(getObject(arg1), arg2);
};
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
imports.wbg.__wbg_downloadBytes_0a24cd39b4d3d8e6 = function(arg0, arg1, arg2) {
downloadBytes(getStringFromWasm0(arg0, arg1), getObject(arg2));
};
imports.wbg.__wbg_keyCode_e19b105e5d2d09d5 = function(arg0) {
var ret = getObject(arg0).keyCode;
return ret;
};
imports.wbg.__wbg_fromCharCode_6265c2392e0a786f = function(arg0) {
var ret = String.fromCharCode(arg0 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = typeof(obj) === 'string' ? obj : undefined;
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
imports.wbg.__wbg_new_6b86a64d95e1bdda = handleError(function(arg0, arg1) {
var ret = new WebSocket(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
});
imports.wbg.__wbg_setbinaryType_fe6256a114c22d1e = function(arg0, arg1) {
getObject(arg0).binaryType = takeObject(arg1);
};
imports.wbg.__wbg_setonopen_c42258145e762057 = function(arg0, arg1) {
getObject(arg0).onopen = getObject(arg1);
};
imports.wbg.__wbg_setonmessage_9806a486d5f51913 = function(arg0, arg1) {
getObject(arg0).onmessage = getObject(arg1);
};
imports.wbg.__wbg_new_b7e3d6adc8b9377a = function(arg0) {
var ret = new Uint8Array(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_length_32e166b42b85060a = function(arg0) {
var ret = getObject(arg0).length;
return ret;
};
imports.wbg.__wbg_set_66e888cef8f00a73 = function(arg0, arg1, arg2) {
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
};
imports.wbg.__wbg_send_2838823723b1a700 = handleError(function(arg0, arg1, arg2) {
getObject(arg0).send(getArrayU8FromWasm0(arg1, arg2));
});
imports.wbg.__wbg_offsetX_42ecbe09df498202 = function(arg0) {
var ret = getObject(arg0).offsetX;
return ret;
};
imports.wbg.__wbg_offsetY_70b516768b17990b = function(arg0) {
var ret = getObject(arg0).offsetY;
return ret;
};
imports.wbg.__wbg_preventDefault_2afcdd3f7ec9efa3 = function(arg0) {
getObject(arg0).preventDefault();
};
imports.wbg.__wbg_changedTouches_5046aca41b2d11ba = function(arg0) {
var ret = getObject(arg0).changedTouches;
return addHeapObject(ret);
};
imports.wbg.__wbg_length_4c6909494a0e02f9 = function(arg0) {
var ret = getObject(arg0).length;
return ret;
};
imports.wbg.__wbg_get_285b1c8d05fedf27 = function(arg0, arg1) {
var ret = getObject(arg0)[arg1 >>> 0];
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_identifier_a476e15c3a85752c = function(arg0) {
var ret = getObject(arg0).identifier;
return ret;
};
imports.wbg.__wbg_clientX_bc61648c02723dc7 = function(arg0) {
var ret = getObject(arg0).clientX;
return ret;
};
imports.wbg.__wbg_clientY_67b12bba9c15ace2 = function(arg0) {
var ret = getObject(arg0).clientY;
return ret;
};
imports.wbg.__wbindgen_closure_wrapper185 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 64, __wbg_adapter_38);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper1611 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 64, __wbg_adapter_29);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper1613 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 64, __wbg_adapter_26);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper178 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 64, __wbg_adapter_35);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper179 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 64, __wbg_adapter_32);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper180 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 64, __wbg_adapter_41);
return addHeapObject(ret);
};
imports['env'] = __wbg_star0;

if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
    input = fetch(input);
}

const { instance, module } = await load(await input, imports);

wasm = instance.exports;
init.__wbindgen_wasm_module = module;

return wasm;

}

export default init;

@chinedufn chinedufn added the bug label Jun 22, 2020
@chinedufn
Copy link
Contributor Author

Ok so from reading Alex's comment from a couple years ago I have a slightly better sense of what env is:

#21 (comment)


So it seems like the issue could be that, for whatever reason, on my CI machine wasm-bindgen isn't modifying this env thing?

Nothing about my crate is #[cfg(target_os = "...")], in case that's relevant.

@chinedufn
Copy link
Contributor Author

chinedufn commented Jun 22, 2020

Ok so according to this issue comment it might be coming from a dependency that has conditional compilation #1907

Is there an easy way to track this sort of thing down other than git bisecting my app until I find the commit that introduced the dep?

@alexcrichton
Copy link
Contributor

Importing from env generally means that there was an unresolved symbol, which while rare does come up frotime to time. Could you gist what the wasm module itself imports from "env"? (the raw output of rustc, that is)

@chinedufn
Copy link
Contributor Author

Oh sweet this is my first time using wasm2wat - cool seeing what a .wasm file really is.

I'm grabbed the lines at the top that started with (import and pasted them into a gist here:

https://gist.github.com/chinedufn/b691dca4ff4d767399cdbd8a9f425d96

@chinedufn
Copy link
Contributor Author

chinedufn commented Jun 23, 2020

It seems like this might be the relevant bit?

(import "env" "_ZN4core9panicking18panic_bounds_check17h95b04dd9865918b6E" (func $_ZN4core9panicking18panic_bounds_check17h95b04dd9865918b6E (type $t2)))


Also I'm compiling with CARGO_PROFILE_RELEASE_LTO=true in case that's relevant information.

@alexcrichton
Copy link
Contributor

Ah yep, indeed! I believe that's a bug fixed in nightly, can you try updating rustc and see if it helps?

@chinedufn
Copy link
Contributor Author

chinedufn commented Jun 23, 2020

Just updated and tried on latest nightly

# rustc -V
rustc 1.46.0-nightly (6bb3dbfc6 2020-06-22)

Worked!

I could've sworn I tried the latest nightly. yesterday... I think I must've only installed it but didn't change it to be my default toolchain.

Cool - I'm all set!!

@Sheraff
Copy link

Sheraff commented Aug 8, 2020

Hello,

I'm extremely new to Rust and I'm having the same issue as described in this thread. Apparently it appears when my cargo.toml contains some cool JS bindings:

[dependencies]
js-sys = "0.3.44"
serde = { version = "1.0", features = ["derive"] }
wasm-bindgen = { version = "0.2.67", features = ["serde-serialize"] }

[dependencies.web-sys]
version = "0.3.4"

or

[dependencies]
wasm-bindgen = "0.2.67"
js-sys = "0.3.44"

[dependencies.web-sys]
version = "0.3.4"
features = ['CanvasRenderingContext2d']

I'm trying to have a WASM script called from a Web Worker to draw on an OffscreenCanvas. The first cargo.toml config was meant to help me pass back the arguments for my JS CanvasRenderingContext2d, and the second one was meant to actually "transfer" the context to rust as a web_sys::CanvasRenderingContext2d.

In either case, adding these features seems to add the import * as __wbg_star0 from 'env'; line at the top of the .js output when I run wasm-pack build --target web.

I have tried with versions rustc 1.45.2 (d3fb005a3 2020-07-31) and rustc 1.47.0-nightly (6c8927b0c 2020-07-26).

Since I don't know what this 'env' is supposed to be and there is no generated file to go along with it, I'm not sure where to look next.

@atanida
Copy link

atanida commented Mar 8, 2021

Ok, to save others the headache, wasm-timer 0.2 also triggers this nightmare:

Uncaught TypeError: Failed to resolve module specifier "env". Relative references must start with either "/", "./", or "../".

Following your explanation I tried Wasm2wat and it gives this:
(import "env" "now" (func $now (type $t3)))

The function that triggers the horror is this one:
let _ = wasm_timer::Delay::new(std::time::Duration::from_secs(2)).await

@johmedr
Copy link

johmedr commented Mar 10, 2021

Hello,

I faced the same issue, with the same wasm2wat output: (import "env" "now" (func $now (type $t3)))

Tracking down to the caller with grep:

(func $instant::wasm::now::hb7af204bf0443e09 (type 3) (result f64)
  (local f64)
   call $now
   local.set 0
   local.get 0
   return)

which bring to the following issue on the parking_lot crate.

Then, adding the following solved my issue:

parking_lot = { version = "0.11.1", features = ["wasm-bindgen"]}

Hope it can help !

bors bot added a commit to dada-lang/dada that referenced this issue Jan 11, 2022
29: Make parking_lot compile for wasm r=nikomatsakis a=brson

Trying to get dada-web to run I hit an error in the wasm's imports. Per rustwasm/wasm-bindgen#2215 (comment) I turned on the wasm-bindgen feature of parking_lot and now dada-web works for me.

Co-authored-by: Brian Anderson <[email protected]>
@ShayRubach
Copy link

I had the same issue while using the SWC rust library. A community member helped me via their discord channel, hope it helps!
See direct link here.

Original message from discord (credit to mischnic!):

@mischnic — Today at 2:25 PM
The env problem can be worked around by doing this (see the linked issue for more details):
https://github.com/parcel-bundler/parcel/blob/8981c8896566ce0e52205707d7a443fddac09bd3/packages/transformers/js/wasm/Cargo.toml#L17-L19

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

No branches or pull requests

6 participants