Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

wasm2js: function table undefined after calling async function

Đang mở
#7,645 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
rust, wasm
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu với các tệp JavaScript do wasm2js tạo ra trong gist được liên kết và revision algokit-core được tham chiếu, sau đó tái hiện đường đi callback bất đồng bộ từ Rust sang JavaScript bằng output của wasm-pack. So sánh module wasm2js bị lỗi với module WASM hoạt động được xung quanh makeMutClosure và __wbindgen_export_3. Được xem là hoàn tất khi đường đi bất đồng bộ không còn đi tới một bảng hàm không xác định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

A wasm2js-transpiled JS module is throwing an error after an async call, but the WASM binary is working just fine. The wasm binary is compiled from a rust crate using wasm-bindgen and then built with wasm-pack. For some context, this async call is to a Rust function that then makes a async call back into JS before returning.

The error in particular is

# Unhandled error between tests
-------------------------------
152 |         try {
153 |             return f(a, state.b, ...args);
154 |         } finally {
155 |             if (--state.cnt === 0) {
156 |                 console.debug("In makeMutClosure", {export3: wasm$1.__wbindgen_export_3, wasm1: wasm$1});
157 |                 wasm$1.__wbindgen_export_3.get(state.dtor)(a, state.b);
                             ^
TypeError: undefined is not an object (evaluating 'wasm$1.__wbindgen_export_3.get')
      at real (/Users/joe/git/algorandfoundation/algokit-core/packages/typescript/algokit_utils/dist/algokit_utils.wasm2js.mjs:157:24)

To be clear, the code after the async function still runs, so this seems to be happening async somewhere. Adding a debug statement to this finally block I can see, export 3, which is the function table, is indeed undefined.

In makeMutClosure {
  export3: undefined,
  wasm1: [Object: null prototype] {
    __wbg_composer_free: [Function: $174],
    __wbindgen_add_to_stack_pointer: [Function: $413],
    __wbindgen_export_0: [Function: $330],
    __wbindgen_export_1: [Function: $341],
    __wbindgen_export_2: [Function: $390],
    __wbindgen_export_4: [Function: $375],
    __wbindgen_export_5: [Function: $358],
    __wbindgen_export_6: [Function: $354],
    addressFromPubKey: [Function: $248],
    addressFromString: [Function: $249],
    assignFee: [Function: $99],
    attachSignature: [Function: $192],
    composer_addTransaction: [Function: $138],
    composer_encode: [Function: $131],
    composer_getSuggestedParams: [Function: $336],
    composer_new: [Function: $261],
    composer_toJSON: [Function: $215],
    composer_toString: [Function: $216],
    composer_transactions: [Function: $77],
    composer_valueOf: [Function: $214],
    decodeTransaction: [Function: $86],
    encodeTransaction: [Function: $164],
    encodeTransactionRaw: [Function: $165],
    estimateTransactionSize: [Function: $199],
    getAlgorandConstant: [Function: legalstub$260],
    getEncodedTransactionType: [Function: $61],
    getTransactionId: [Function: $163],
    getTransactionIdRaw: [Function: $162],
    memory: {
      grow: [Function: __wasm_memory_grow],
      buffer: [Getter],
    },
  },
}

The same debug statement when using the WASM binary:

In makeMutClosure {
  export3: Table {
    length: 225,
    grow: [Function: grow],
    get: [Function: get],
    set: [Function: set],
    type: [Function: type],
  },
  wasm: [Object: null prototype] {
    memory: Memory {
      grow: [Function: grow],
      buffer: ArrayBuffer(1179648) [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... 1179135 more ],
      type: [Function: type],
    },
    composer_addTransaction: [Function: 198],
    composer_encode: [Function: 191],
    composer_getSuggestedParams: [Function: 396],
    composer_transactions: [Function: 137],
    __wbg_composer_free: [Function: 234],
    composer_new: [Function: 321],
    composer_valueOf: [Function: 274],
    composer_toJSON: [Function: 275],
    composer_toString: [Function: 276],
    getEncodedTransactionType: [Function: 121],
    encodeTransaction: [Function: 224],
    encodeTransactionRaw: [Function: 225],
    decodeTransaction: [Function: 146],
    attachSignature: [Function: 252],
    estimateTransactionSize: [Function: 259],
    addressFromPubKey: [Function: 308],
    addressFromString: [Function: 309],
    getTransactionIdRaw: [Function: 222],
    getTransactionId: [Function: 223],
    getAlgorandConstant: [Function: 320],
    assignFee: [Function: 159],
    __wbindgen_export_0: [Function: 390],
    __wbindgen_export_1: [Function: 401],
    __wbindgen_export_2: [Function: 450],
    __wbindgen_export_3: Table {
      length: 225,
      grow: [Function: grow],
      get: [Function: get],
      set: [Function: set],
      type: [Function: type],
    },
    __wbindgen_add_to_stack_pointer: [Function: 473],
    __wbindgen_export_4: [Function: 435],
    __wbindgen_export_5: [Function: 418],
    __wbindgen_export_6: [Function: 414],
  },
}

The JS files: https://gist.github.com/joe-p/0b12f34e45f5152043f3948d34572e40
The repo: https://github.com/algorandfoundation/algokit-core/tree/2b2eba2c60b0a6d008a4a15bbfa3a76374b04441/packages/typescript/algokit_utils

Ngôn ngữ chính
WebAssembly
Star
8.6k
Fork
885
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
77

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của WebAssembly/binaryen

Tất cả issue của WebAssembly/binaryen

Issue tương tự

Thêm issue về Compilers

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.