Skip to content

AlarmKit: surface errors, fix unresumed continuation, cancel fallback, Nitro 0.37 - #28

Merged
robertherber merged 1 commit into
mainfrom
fix/alarm-errors-and-nitro-0.37
Nov 12, 2026
Merged

robertherber merged 1 commit into
mainfrom
fix/alarm-errors-and-nitro-0.37

Conversation

@robertherber

Copy link
Copy Markdown
Member

Summary

Found while debugging kingstinct/undistractable: a running countdown could not be stopped from the app, and every AlarmKit error on that path was either swallowed or lost.

  • requestAuthorization() could hang forever. The withCheckedThrowingContinuation wrapper only resumed on success; a thrown error left the continuation unresumed and the JS promise never settled. Both it and scheduleAlarm now use Promise.async directly and reject.
  • Errors carry context. cancel(), stop(), pause(), resume() and countdown() throw AlarmOperationError with the operation, alarm id, state and the underlying AlarmKit error, so the JS side sees e.g. AlarmKit cancel failed for alarm … in state countdown: … instead of a bare error.
  • cancel() fallback. When AlarmKit refuses the first cancel(id:), the alarm is stopped and cancelled again, unless stopping already removed it.
  • No fatalError on unknown Alarm.State. A state added by a newer iOS maps to scheduled.
  • One AlarmState enum. AlarmKitModule.nitro.ts declared a second AlarmState with a different member order (alerting = 1, countdown = 2) than AlarmProxy.nitro.ts (countdown = 1, alerting = 3); it now re-exports the proxy's enum.
  • Nitro 0.37. nitrogen and react-native-nitro-modules 0.37.1, AnyMap BigInt → Int64, peer dependency react-native-nitro-modules >= 0.37.0. Bindings regenerated with bun run specs.

The same native changes ship as a bun patch in the app until this is released.

Test plan

  • bun run typecheck, bun run lint, bun run specs in this repo
  • The app compiles with these Swift changes (Xcode 27.1, iOS 27.2 SDK)
  • On device: cancelling a countdown alarm from the app; a refused cancel now surfaces its error

🤖 Generated with Claude Code

…, Nitro 0.37

Found while debugging an app whose running countdown could not be stopped
from the app: every AlarmKit error was either swallowed or lost.

- requestAuthorization() left its continuation unresumed on error, so the
  JS promise never settled; it now rejects.
- Alarm operations throw AlarmOperationError with the operation, alarm id,
  state and the underlying AlarmKit error.
- cancel() falls back to stop(id:) + cancel(id:) when AlarmKit refuses the
  first cancel, unless stopping already removed the alarm.
- An unknown Alarm.State maps to scheduled instead of fatalError.
- AlarmKitModule.nitro.ts re-exports AlarmState from AlarmProxy.nitro.ts
  instead of declaring a second enum with a different member order.
- nitrogen / react-native-nitro-modules 0.37.1 (AnyMap BigInt -> Int64),
  peer dependency react-native-nitro-modules >= 0.37.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9fda584

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kingstinct/react-native-activity-kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/kingstinct/react-native-activity-kit/@kingstinct/react-native-activity-kit@28

commit: 9fda584

@robertherber
robertherber merged commit 0e7ddcb into main Nov 12, 2026
5 of 6 checks passed
@robertherber
robertherber deleted the fix/alarm-errors-and-nitro-0.37 branch November 12, 2026 02:08
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.

1 participant