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

deno compile: node addons gets error missing symbol called #24614

Open
Mutefish0 opened this issue Jul 17, 2024 · 1 comment · May be fixed by #24775
Open

deno compile: node addons gets error missing symbol called #24614

Mutefish0 opened this issue Jul 17, 2024 · 1 comment · May be fixed by #24775
Labels
bug Something isn't working correctly compile related to the `deno compile` feature node native extension related to the node-api (.node)

Comments

@Mutefish0
Copy link
Contributor

Mutefish0 commented Jul 17, 2024

require('xxx.node') will get error missing symbol called after deno compile.

Version:

deno 1.45.1 (release, aarch64-apple-darwin)
v8 12.7.224.12
typescript 5.5.2

Reproduce

copy file audio.node: https://github.com/Mutefish0/deno-node-addons-issue/blob/master/audio.node

create main.ts

import Module from 'node:module'
import path from "node:path";

const standalone = Deno.args.includes("--standalone");

export function resolvePath(url: string, metaUrl: string) {
  let baseDir = "";
  if (standalone) {
    baseDir = path.dirname(Deno.execPath());
  } else {
    baseDir = path.dirname(metaUrl);
  }
  baseDir = baseDir.replace("file://", "");
  return path.resolve(baseDir, url);
}

const mod = new Module('')

const url = resolvePath("./audio.node", import.meta.url);


if (Deno.statSync(url).isFile) {
  const m = mod.require(url);
  console.log(m);
}

compile and run:

deno compile  --allow-ffi --allow-read   --output ./main  ./main.ts --standalone
./main

then the error occurs:
截屏2024-07-17 下午1 24 34

deno run:

deno run --allow-ffi --allow-read  ./main.ts

works fine:

截屏2024-07-17 下午1 30 00

reproduce repo: https://github.com/Mutefish0/deno-node-addons-issue

@littledivy littledivy added bug Something isn't working correctly compile related to the `deno compile` feature node native extension related to the node-api (.node) labels Jul 17, 2024
devsnek pushed a commit that referenced this issue Jul 21, 2024
Currently, importing Node-Addons modules in a standalone binary results
in a `missing symbol called` error
(#24614). Because the NAPI
symbols are not exported in this mode. This PR should fix the issue.
bartlomieju pushed a commit that referenced this issue Jul 22, 2024
Currently, importing Node-Addons modules in a standalone binary results
in a `missing symbol called` error
(#24614). Because the NAPI
symbols are not exported in this mode. This PR should fix the issue.
@Mutefish0 Mutefish0 reopened this Jul 24, 2024
@Mutefish0
Copy link
Contributor Author

Reopen the issue since the PR(#24642) was reverted.
@devsnek Can this PR get relanded or is there any plan to address this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly compile related to the `deno compile` feature node native extension related to the node-api (.node)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants