fix(zboss): make permitJoin loud when the driver is not initialized - #1829
fix(zboss): make permitJoin loud when the driver is not initialized#1829tostmann wants to merge 1 commit into
Conversation
permitJoin() wraps its entire body in `if (this.driver.isInitialized())` with no else branch: called while the driver is not initialized, the request simply evaporates — no log, no error — and the application above reports the permit as successful although nothing was sent. That silent shape turns any join problem in this state into a dead-end diagnosis. Add the missing else: log an explicit error stating the request was ignored and the network state unchanged. Deliberately log-only rather than a throw — the guard also covers internal timer-driven calls around shutdown, where a rejection would surface as an unhandled one. Happy to switch to a throw if that contract is preferred.
|
I would assume it shouldn't be possible for permitJoin to ever be called if the driver is not initialized. Once |
|
Agreed — in the upstream flows that state shouldn't be reachable: once The wrinkle is that the guard already exists in So there are two consistent ways to express "this can't happen":
Happy to rework the PR to (1) if that's the preferred contract — it's the cleaner expression of the assumption. |
|
I'd say 1, but let's wait confirmation from @Koenkk @kirovilya |
|
@kirovilya could you check? |
permitJoin()wraps its entire body inif (this.driver.isInitialized())with no else branch. Called while the driver is not initialized, the request simply evaporates — no log, no error — and the application above reports the permit as successful although nothing was sent on the wire. During a recent debugging session this exact shape cost hours: "the network never opens although permit_join returns ok" with nothing in any log to point at the guard.This adds the missing else: an explicit
logger.errorstating the request was ignored and the network state unchanged.Deliberately log-only rather than a throw, since the guard also covers internal timer-driven calls around shutdown, where a rejection would surface as an unhandled one — but happy to switch to a throw if you prefer that contract.
Covered by a unit test (spied logger, fake uninitialized driver: resolves without throwing, error line emitted) that fails on the previous code. Full vitest suite and
pnpm run checkgreen.