You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(runtime): session-title deadline-abort test hangs under full-suite load on main #1222
packages/runtime/src/__tests__/session-title.test.ts 的 aborts title generation when the provider exceeds its deadline(#1199 引入)在当前 main(8b9d69a)上跑 npm --workspace @maka/runtime run test 时稳定失败:
not ok 6 - aborts title generation when the provider exceeds its deadline
failureType: 'cancelledByParent'
error: 'Promise resolution is still pending but the event loop has already resolved'
With nothing else scheduled, the event loop can drain before the 10 ms timer ever fires → the race promise is left pending → node:test reports cancelledByParent: 'Promise resolution is still pending but the event loop has already resolved'.
Whether it reproduces then depends on incidental keep-alives in the process (Node version internals, leftover timers from sibling tests in the same process), which is why it looks load-dependent — it's really a liveness race.
Suggested fix: in generateSessionTitle, drive the timeout branch of the Promise.race with an explicit (ref'ed) setTimeout that is cleared once the race settles, instead of piggybacking on AbortSignal.timeout's unref'ed timer. That keeps the loop alive deterministically and also makes the test independent of Node-version event-loop behavior. (An AbortController + abortController.abort(reason) from that same timer can still feed the abortSignal passed to generateText.)
Repro used: packages/runtime → npm run build && node --test dist/__tests__/session-title.test.js, toggling Node via nvm between 22.17.0 and 24.18.0.
Activity
Colafornia commentedon Jul 19, 2026
Thanks for reporting this — I’m working on a fix.
UncertaintyDeterminesYou4ndMe commentedon Jul 19, 2026
Some additional data points that may help — the "full-suite load vs single-file" split doesn't hold on my machine; the Node version does:
node --test dist/__tests__/session-title.test.js(single file)cancelledByParent, same error as above)So the deciding factor doesn't seem to be suite load per se, but whether anything else happens to keep the event loop alive for those 10 ms.
Root cause hypothesis:
generateTextreturns a promise that never resolves — it only registers anabortlistener.AbortSignal.timeout(), whose internal timer is unref'ed and does not keep the Node.js event loop active.node:testreportscancelledByParent: 'Promise resolution is still pending but the event loop has already resolved'.Whether it reproduces then depends on incidental keep-alives in the process (Node version internals, leftover timers from sibling tests in the same process), which is why it looks load-dependent — it's really a liveness race.
Suggested fix: in
generateSessionTitle, drive the timeout branch of thePromise.racewith an explicit (ref'ed)setTimeoutthat is cleared once the race settles, instead of piggybacking onAbortSignal.timeout's unref'ed timer. That keeps the loop alive deterministically and also makes the test independent of Node-version event-loop behavior. (AnAbortController+abortController.abort(reason)from that same timer can still feed theabortSignalpassed togenerateText.)Repro used:
packages/runtime→npm run build && node --test dist/__tests__/session-title.test.js, toggling Node via nvm between 22.17.0 and 24.18.0.test(runtime): stabilize session title timeout test (apache#1222)
test(runtime): stabilize session title timeout test (apache#1222)
test(runtime): stabilize session title timeout test (#1222) (#1225)