Skip to content

[BUG] Uncaught LinkError #220

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

Closed
1 task done
Miaxos opened this issue Sep 1, 2022 · 1 comment
Closed
1 task done

[BUG] Uncaught LinkError #220

Miaxos opened this issue Sep 1, 2022 · 1 comment

Comments

@Miaxos
Copy link

Miaxos commented Sep 1, 2022

Is there an existing issue for this?

  • I have searched the existing issues

What version of workers-rs are you using?

0.0.11

Describe the bug

✘ [ERROR] Error on remote worker: ParseError: A request to the Cloudflare API
(/accounts/<AccountID>/workers/scripts/<scriptName>/edge-preview) failed.

      at throwFetchError (/Users/<someone>/.n/lib/node_modules/wrangler/wrangler-dist/cli.js:141293:17)
      at fetchResult (/Users/<someone>/.n/lib/node_modules/wrangler/wrangler-dist/cli.js:141262:5)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async createPreviewToken
  (/Users/<someone>/.n/lib/node_modules/wrangler/wrangler-dist/cli.js:141555:29)
      at async createWorkerPreview
  (/Users/<someone>/.n/lib/node_modules/wrangler/wrangler-dist/cli.js:141575:17)
      at async start (/Users/<someone>/.n/lib/node_modules/wrangler/wrangler-dist/cli.js:142271:34) {
    text: 'A request to the Cloudflare API
  (/accounts/<AccountID>/workers/scripts/<scriptName>/edge-preview) failed.',
    notes: [
      {
        text: 'Uncaught LinkError: WebAssembly.Instance(): Import #45 module="./index_bg.js"
  function="__wbg_clearTimeout_65417660fe82f08d" error: function import requires a callable\n' +
          '  at shim.js:135:16\n' +
          ' [code: 10021]'
      }
    ],
    location: undefined,
    kind: 'error',
    code: 10021
  }

Steps To Reproduce

On macos (M1)

As soon as you use clearTimeout function.

use js_sys::Function;
use wasm_bindgen::prelude::*;
use wasm_bindgen::{JsCast, JsValue};

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_name = "setTimeout", catch)]
    fn set_timeout(handler: &Function, timeout: i32) -> std::result::Result<i32, JsValue>;

    #[wasm_bindgen(js_name = "setInterval", catch)]
    fn set_interval(handler: &Function, timeout: i32) -> std::result::Result<i32, JsValue>;

    #[wasm_bindgen(js_name = "clearTimeout")]
    fn clear_timeout(handle: i32);

    #[wasm_bindgen(js_name = "clearInterval")]
    fn clear_interval(handle: i32);
}

You create a timeout then clear it, the generated shim.mjs will have this line:

var __wbg_clearTimeout_412b3cc7b151def7 = typeof clearTimeout == "function" ? clearTimeout : notDefined("clearTimeout");

And it'll trigger the error

@Miaxos
Copy link
Author

Miaxos commented Sep 1, 2022

rustwasm/gloo#249 gave me the answer, the issue was not linked to worker-rs.

@Miaxos Miaxos closed this as completed Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant