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

Using await before go.run(inst) of wasm_exec await indefinitely #49710

Open
oliverlj opened this issue Nov 21, 2021 · 2 comments
Open

Using await before go.run(inst) of wasm_exec await indefinitely #49710

oliverlj opened this issue Nov 21, 2021 · 2 comments

Comments

@oliverlj
Copy link

@oliverlj oliverlj commented Nov 21, 2021

What version of Go are you using (go version)?

$ go version
go version go1.17.2 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
❯ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oliver/.cache/go-build"
GOENV="/home/oliver/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/oliver/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/oliver/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.17"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.17/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2669847847=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Trying to run wasm module with await, then wait is lock

export async function loadCff2Wasm() {
  const go = new Go();
  const result = await WebAssembly.instantiateStreaming(fetch('cff2.wasm'), go.importObject);

  go.run(result.instance);
  // workaround, if I put await before go.run, promise never resolve
  await new Promise((resolve) => setTimeout(resolve, 1000));
}

I'm using it with an ember service. calling fetchTransactions will run indefinitely.

import { tracked } from '@glimmer/tracking';
import Service from '@ember/service';

import { loadCff2Wasm } from 'cryptofiscafacile-wasm';
import { dropTask, enqueueTask, task, timeout } from 'ember-concurrency';
import { perform } from 'ember-concurrency-ts';

import type { TxData } from 'cryptofiscafacile-wasm';

export default class WasmService extends Service {
  #cff2WasmLoaded = false;

  @tracked
  transactions?: TxData;

  @enqueueTask
  async loadCff2WasmTask() {
    if (!this.#cff2WasmLoaded) {
      await loadCff2Wasm();
      this.#cff2WasmLoaded = true;
    }
  }

  @task
  async getTransactionsTask() {
    await perform(this.loadCff2WasmTask);

    this.transactions = await getTransactions();
  }

  async fetchTransactions() {
    perform(this.getTransactionsTask);
  }
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Nov 22, 2021

can you provide a self contained reproducer?

Loading

@heschi
Copy link
Contributor

@heschi heschi commented Nov 22, 2021

Loading

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

Successfully merging a pull request may close this issue.

None yet
3 participants