-
Notifications
You must be signed in to change notification settings - Fork 79
Support setting domain id for Context #1164
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
Conversation
There was a problem hiding this comment.
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 adds support for setting the domain id for the Context, ensuring that the domain id is handled and returned as a BigInt throughout the API. Key changes include:
- Adjusting type assertions in tests to expect BigInt for domain ids.
- Updating the C++ bindings to accept an optional BigInt argument and return a BigInt.
- Modifying the Context API and initialization code in JavaScript to handle the new domain id.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/types/index.test-d.ts | Updated tests to verify the new BigInt type for domain id. |
| test/test-context.js | Modified tests to reflect the updated domain id expectations. |
| src/rcl_context_bindings.cpp | Changed bindings to accept and return BigInt; added scope_exit for cleanup. |
| lib/context.js | Updated the Context constructor and getter to use domain id as BigInt. |
| index.js | Passed the domain id from the Context instance to the initialization API. |
Comments suppressed due to low confidence (1)
lib/context.js:68
- [nitpick] Consider providing a default value (e.g., 0n) for the domainId parameter in the Context constructor to ensure that this._domainId is always a BigInt, which will clarify the API contract for users.
constructor(domainId) {
| size_t domain_id = RCL_DEFAULT_DOMAIN_ID; | ||
| if (info.Length() > 2 && info[2].IsBigInt()) { | ||
| bool lossless; | ||
| domain_id = info[2].As<Napi::BigInt>().Uint64Value(&lossless); |
Copilot
AI
Jun 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider checking if the BigInt conversion was lossless by verifying the 'lossless' boolean value; if the conversion is not lossless, it may be appropriate to throw an error to prevent potential data truncation.
| domain_id = info[2].As<Napi::BigInt>().Uint64Value(&lossless); | |
| domain_id = info[2].As<Napi::BigInt>().Uint64Value(&lossless); | |
| if (!lossless) { | |
| Napi::Error::New(env, "BigInt conversion to domain_id was not lossless") | |
| .ThrowAsJavaScriptException(); | |
| return env.Undefined(); | |
| } |
This PR adds support for setting the domain id for the Context, ensuring that the domain id is handled and returned as a BigInt throughout the API. Key changes include: - Adjusting type assertions in tests to expect BigInt for domain ids. - Updating the C++ bindings to accept an optional BigInt argument and return a BigInt. - Modifying the Context API and initialization code in JavaScript to handle the new domain id. Fix: #1163
This PR adds support for setting the domain id for the Context, ensuring that the domain id is handled and returned as a BigInt throughout the API. Key changes include:
Fix: #1163