Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Server crashed returned when trying wasm-emscripten with Sapper #849

Closed
hepiBatman opened this issue Aug 16, 2019 · 0 comments
Closed

Server crashed returned when trying wasm-emscripten with Sapper #849

hepiBatman opened this issue Aug 16, 2019 · 0 comments

Comments

@hepiBatman
Copy link

Describe the bug
Attempting to get emscripten wasm working with Sapper. The wasm files are from Google Sqoosh but it can be any emscripten wasm file.
Emscripten generated code uses fs, but on the client-side you can use webpack.IgnorePlugin so app avoids fs and the whole thing works https://github.com/hepiBatman/webpack-wasm-emscripten.

Sapper, on the other hand, by default is server-side rendering, causing to use fs library to load wasm and causing error because it does not file the wasm files.

Logs

{ Error: ENOENT: no such file or directory, open 'mozjpeg_enc.93395.wasm'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.shell_read [as read] (webpack:///./wasm/mozjpeg_enc.js?:8:1239)
    at Object.readBinary (webpack:///./wasm/mozjpeg_enc.js?:8:1357)
    at getBinary (webpack:///./wasm/mozjpeg_enc.js?:8:14410)
    at eval (webpack:///./wasm/mozjpeg_enc.js?:8:14931)
    at new Promise (<anonymous>)
    at getBinaryPromise (webpack:///./wasm/mozjpeg_enc.js?:8:14885)
    at instantiateArrayBuffer (webpack:///./wasm/mozjpeg_enc.js?:8:15859)
    at doNativeWasm (webpack:///./wasm/mozjpeg_enc.js?:8:16477)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'mozjpeg_enc.93395.wasm' }
failed to asynchronously prepare wasm: abort({"errno":-2,"code":"ENOENT","syscall":"open","path":"mozjpeg_enc.93395.wasm"}). Build with -s ASSERTIONS=1 for more info.
abort({"errno":-2,"code":"ENOENT","syscall":"open","path":"mozjpeg_enc.93395.wasm"}). Build with -s ASSERTIONS=1 for more info.
abort("abort({\"errno\":-2,\"code\":\"ENOENT\",\"syscall\":\"open\",\"path\":\"mozjpeg_enc.93395.wasm\"}). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info.

webpack:///./wasm/mozjpeg_enc.js?:8
var Module=typeof mozjpeg_enc!=="undefined"?mozjpeg_enc:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&"function"==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}else{return scriptDirectory+path}}if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";var nodeFS;var 
abort("abort(\"abort({\\\"errno\\\":-2,\\\"code\\\":\\\"ENOENT\\\",\\\"syscall\\\":\\\"open\\\",\\\"path\\\":\\\"mozjpeg_enc.93395.wasm\\\"}). Build with -s ASSERTIONS=1 for more info.\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info.
> Server crashed

From https://github.com/sveltejs/sapper/issues/383, I have followed https://github.com/timhall/sapper-spa but it appears this is only for the view.

To Reproduce
https://github.com/hepiBatman/svelte-wasm-emscripten

Expected behavior
Sapper to allow wasm emscripten to work.

Information about your Sapper Installation:

  • Your browser and the version: Chrome 76.0.3809.100

  • Your operating system: OS X 10

  • Your hosting environment: Local

  • Sapper version: latest

  • Svelte version: latest

  • If it is an exported (npm run export) or dynamic application.: dynamic

  • Whether your application uses Webpack or Rollup: Webpack

Severity
Unable to develop app with Svelte wasm emscripten.

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

No branches or pull requests

1 participant