Skip to content

Fix DLL load failure on Windows for paths containing non-ANSI characters#743

Merged
baijumeswani merged 3 commits into
mainfrom
baijumeswani/accept-non-ascii-paths-js
May 29, 2026
Merged

Fix DLL load failure on Windows for paths containing non-ANSI characters#743
baijumeswani merged 3 commits into
mainfrom
baijumeswani/accept-non-ascii-paths-js

Conversation

@baijumeswani

Copy link
Copy Markdown
Collaborator

The JS SDK's native add-on fails to load onnxruntime.dll (and other dependency libraries) when the path contains characters outside the active Windows ANSI code page. Customers running the SDK from a profile directory with non-ascii characters see:

Failed to load dependency library: C:\Users\<non-ascii-name>\…\onnxruntime.dll

sdk/js/native/foundry_local_napi.c used LoadLibraryA, which interprets the path bytes as the active ANSI code page. N-API hands us a lossless UTF-8 string, but LoadLibraryA then mis-decodes those bytes and the loader returns ERROR_MOD_NOT_FOUND.

This pull-request routesWindows library loads through LoadLibraryW with a UTF-16 path fetched via napi_get_value_string_utf16. POSIX behaviour is unchanged (dlopen is already UTF-8).

Copilot AI review requested due to automatic review settings May 29, 2026 19:16
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment May 29, 2026 7:39pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Windows-specific DLL loading failure in the JS SDK’s native N-API add-on when library paths contain characters outside the active ANSI code page, by routing Windows loads through LoadLibraryW using UTF-16 paths sourced from N-API.

Changes:

  • Introduces open_lib_from_napi() to load libraries from N-API string values, using LoadLibraryW on Windows and dlopen on POSIX.
  • Updates loadLibrary(corePath, depPaths?) to use the new helper for dependency and core library loading.
  • Removes the LoadLibraryA-based LIB_OPEN macro usage and documents the rationale.

Comment thread sdk/js/native/foundry_local_napi.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread sdk/js/native/foundry_local_napi.c
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@baijumeswani baijumeswani merged commit 98b9e4c into main May 29, 2026
80 checks passed
@baijumeswani baijumeswani deleted the baijumeswani/accept-non-ascii-paths-js branch May 29, 2026 22:31
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

Successfully merging this pull request may close these issues.

3 participants