DjDeveloperr/deno-canvas

Error when trying to run example

rodigu opened this issue · 1 comments

When I try running the example code:

import Canvas from 'https://deno.land/x/canvas@v1.1.1/mod.ts'
import { serve } from "https://deno.land/std@0.89.0/http/server.ts";

const canvas = Canvas.MakeCanvas(200, 200);
const ctx = canvas.getContext('2d');

ctx.fillStyle = 'red';
ctx.fillRect(10, 10, 200 - 20, 200 - 20);

const server = serve({ hostname: "0.0.0.0", port: 8080 });
console.log(`HTTP webserver running. Access it at: http://localhost:8080/`);

for await (const request of server) {
  request.respond({ status: 200, body: canvas.toBuffer() });
}

And then use the command deno run --allow-net main.ts (file name is main), I get the following error:

both async and sync fetching of the wasm failed
failed to asynchronously prepare wasm: RuntimeError: abort(both async and sync fetching of the wasm failed). Build with -s ASSERTIONS=1 for more info.
RuntimeError: abort(both async and sync fetching of the wasm failed). Build with -s ASSERTIONS=1 for more info.
    at Ia (https://deno.land/x/canvas@v1.1.1/lib.js:430:73)
    at Gb (https://deno.land/x/canvas@v1.1.1/lib.js:431:158)
    at https://deno.land/x/canvas@v1.1.1/lib.js:431:480
error: Uncaught (in promise) RuntimeError: abort(RuntimeError: abort(both async and sync fetching of the wasm failed). Build with -s ASSERTIONS=1 for more info.). Build with -s ASSERTIONS=1 for more info.
    at Ia (https://deno.land/x/canvas@v1.1.1/lib.js:430:73)
    at https://deno.land/x/canvas@v1.1.1/lib.js:708:435

Example used outdated version which broke in new version of Deno. Updated it, thanks!