Skip to content

[nodejs] support Node.js binding in multi env#24366

Merged
fs-eire merged 6 commits intomainfrom
fs-eire/nodejs-add-test-worker
Apr 16, 2025
Merged

[nodejs] support Node.js binding in multi env#24366
fs-eire merged 6 commits intomainfrom
fs-eire/nodejs-add-test-worker

Conversation

@fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Apr 9, 2025

Description

Implemented a thread safe OrtInstanceData to support Node.js binding in multi env, and add an E2E test for running in worker.

Motivation and Context

@fs-eire fs-eire marked this pull request as draft April 10, 2025 18:31
@fs-eire
Copy link
Contributor Author

fs-eire commented Apr 10, 2025

Nodejs binding implementation need to resolve racing condition. (WIP)

@fs-eire fs-eire changed the title [nodejs] add an E2E test for running in worker [nodejs] support Node.js binding in multi env Apr 11, 2025
@fs-eire fs-eire marked this pull request as ready for review April 11, 2025 19:16
@fs-eire
Copy link
Contributor Author

fs-eire commented Apr 11, 2025

implementation ready for review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

js/node/src/ort_instance_data.cc:7

  • The direct inclusion of <Windows.h> may cause build issues on non-Windows platforms; consider wrapping it within a platform-specific conditional compilation block (e.g., #ifdef _WIN32) to ensure cross-platform compatibility.
#include <Windows.h>

js/node/src/inference_session_wrap.cc:80

  • Dereferencing OrtInstanceData::OrtEnv() assumes that the global Ort::Env has been properly initialized; consider adding safeguards or ensuring that this precondition is met in all multi-threaded environments.
this->session_.reset(new Ort::Session(*OrtInstanceData::OrtEnv(),

@fs-eire fs-eire requested a review from Copilot April 11, 2025 22:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@fs-eire fs-eire merged commit ec02406 into main Apr 16, 2025
85 of 89 checks passed
@fs-eire fs-eire deleted the fs-eire/nodejs-add-test-worker branch April 16, 2025 15:33
fs-eire added a commit that referenced this pull request Apr 16, 2025
### Description

Update N-API version to 6.

- NAPI v6 is required for `napi_set_instance_data` and
`napi_get_instance_data`, as used by #24366
- Adding the "binary" field in package.json for CMake-js to work
correctly. (was unintentially removed in #24418)

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
ashrit-ms pushed a commit that referenced this pull request Apr 24, 2025
### Description


Implemented a thread safe OrtInstanceData to support Node.js binding in
multi env, and add an E2E test for running in worker.


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
ashrit-ms pushed a commit that referenced this pull request Apr 24, 2025
### Description

Update N-API version to 6.

- NAPI v6 is required for `napi_set_instance_data` and
`napi_get_instance_data`, as used by #24366
- Adding the "binary" field in package.json for CMake-js to work
correctly. (was unintentially removed in #24418)

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
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