Conversation
The gateway reports time-conditional orders that are being monitored, before they are reported to the exchange, with the order status `DelayedNotReported` (see longbridge/developers#1263). No SDK enum matched it, so `impl_serde_for_enum_string!`'s `unwrap_or_default()` turned it into `OrderStatus::Unknown` — monitoring orders were indistinguishable from a genuinely unrecognized status in `today_orders` / `history_orders` / `order_detail` and the order-changed push. Added across all six layers: Rust, C (header regenerated by cbindgen), C++ (enum plus both conversion directions), Java (JNI list plus the Java enum), Node.js (`index.d.ts` regenerated) and Python (plus the `openapi.pyi` stub). The variant is appended after `PartialWithdrawal` rather than placed next to the other `*NotReported` values: the C/C++ and Node.js enums use implicit discriminants, so inserting mid-list would renumber every following value — an ABI break for the C/C++ bindings, and a silent mismatch for TypeScript code that inlined the old `const enum` values.
The committed index.js was generated by an older CLI than the 3.8.6 the
release workflow pins, so regenerating it alongside index.d.ts produces
loader churn unrelated to the enum change. Committing it here keeps the
two generated files in step with each other and with CI.
What the regenerated loader changes:
- `require('node:fs')` → `require('fs')` and the optional chaining in the
musl / win32 probes is expanded, restoring older-Node compatibility
- NAPI_RS_FORCE_WASI is now tri-state ('true' / 'error' / unset) instead
of any-non-empty-string truthy, so NAPI_RS_FORCE_WASI=false or =0 no
longer takes the WASI path and fails with ENOENT
- adds NAPI_RS_WASI_FLAVOR for selecting one exact generated flavor
- WASI candidates are resolved before being required, and the load-error
chain is built without mutating the original errors; `error.cause` is
assigned rather than passed to the Error options form, which Node
< 16.9 ignores
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows longbridge/developers#1263, which documents the new
DelayedNotReportedorder status — 监控中 (时间条件单), the state a time-conditional order sits in before it is reported to the exchange.Problem
No SDK enum variant matched that wire value.
OrderStatusdeserializes throughimpl_serde_for_enum_string!, which falls back tounwrap_or_default()→OrderStatus::Unknown, so nothing failed loudly — monitoring time-conditional orders simply became indistinguishable from a genuinely unrecognized status intoday_orders/history_orders/order_detailand the order-changed push.Changes
All six layers, per the checklist in
CLAUDE.md:rust/src/trade/types.rs(#[strum(serialize = "DelayedNotReported")])c/src/trade_context/enum_types.rs;longbridge.hregenerated by cbindgencpp/include/types.hpp+ both conversion directions incpp/src/convert.hppjava/src/types/enum_types.rs+java/javasrc/.../trade/OrderStatus.javanodejs/src/trade/types.rs;index.d.tsregenerated bynpm run build:debugpython/src/trade/types.rs+ theopenapi.pyistubWhy the variant is appended instead of grouped
The natural place would be next to the other
*NotReportedvalues, matching the docs table. It is appended afterPartialWithdrawalinstead, because the C/C++ and Node.js enums use implicit discriminants:lb_order_status_tinlongbridge.hhas no explicit values — inserting mid-list shifts every following one, an ABI break for anything linked against a prebuilt C/C++ library.nodejs/index.d.tsemitsexport declare const enum OrderStatus { … Filled = 5 … }, and TypeScript inlinesconst enummembers at the consumer's compile time. A renumbering would make already-compiled application code read its hard-coded5as a different status — a silent mismatch rather than a build error.Appending keeps every existing discriminant stable (
DelayedNotReported = 18in TS). The declaration order does not have to match the docs table.Second commit: regenerated
nodejs/index.jsnpm run build:debugregeneratesindex.jsalongsideindex.d.ts, and the committed copy turns out to predate the@napi-rs/cli@3.8.6the release workflow pins — so it comes back with ~160 lines of loader churn that has nothing to do with the enum. It is committed separately (38184a7) to bring the two generated files back in step with each other and with CI. Review it as a standalone change; what the newer generator emits:require('node:fs')→require('fs'), and the optional chaining in the musl / win32 probes is expanded — older-Node compatibilityNAPI_RS_FORCE_WASIbecomes tri-state ('true'/'error'/ unset) instead of any-non-empty-string truthy, soNAPI_RS_FORCE_WASI=falseor=0no longer takes the WASI path and fails with ENOENTNAPI_RS_WASI_FLAVORfor pinning one exact generated flavorrequire.resolve'd before being required, and the load-error chain is built without mutating the original errors;error.causeis assigned rather than passed via theErroroptions form, which Node < 16.9 ignoresVerification
cargo clippy --all --all-features— no new warningscargo +nightly fmt --allcargo build -p longbridge-c— header regeneratedg++ -fsyntax-only -std=c++17overcpp/src/convert.hpp— bothconvert()overloads compilenpm run build:debug—index.d.ts/index.jsregenerated🤖 Generated with Claude Code