Skip to content

fix: after-middleware re-entry, notification read state, and DotPath/type/build fixes - #11

Merged
3m1n3nc3 merged 6 commits into
mainfrom
fix/after-middleware-notifications-types
Oct 10, 2026
Merged

3m1n3nc3 merged 6 commits into
mainfrom
fix/after-middleware-notifications-types

Conversation

@3m1n3nc3

Copy link
Copy Markdown
Member

Summary

Bug fixes found while building notifications on Arkstack 0.19 in an app, plus pre-existing typecheck and build failures in the repo.

driver-express: after middleware re-entered the router (c9a33219)

after middleware ran on the response's finish event with the request's real next(). A middleware that calls next() (as requestLogger() does) therefore sent every request back through the remaining routes after the response had been sent. Downstream layers then raised Cannot set headers after they are sent to the client, and a handler could in principle run twice. It now receives a no-op next, and its errors are logged. Regression tests cover Express and H3; H3 was not affected.

notifications: read state (87025435)

  • UserNotificationCenter.markAllRead() used arkormx's single-row update(), so it marked one notification. It now uses updateFrom().
  • unreadForUser(user, perPage) never passed perPage to paginate().
  • Both now filter unread rows with whereNull('readAt').

common: DotPath recursion (f1d68455)

DotPath, the key type behind config() and configure(), recursed without limit into every object. A config holding nodemailer transports therefore failed tsc in the Express templates with "circularly references itself" wherever config() was called. It is now depth-bounded (7) and stops at built-in object types. This also removes the @ts-expect-error workarounds in the H3 template and in notifications/src/config.ts.

Pre-existing build and type failures (48c2a53d)

  • build:templates ran each template's prebuild in parallel. Each one rebuilt the shared packages at once, so the builds clobbered each other's output and the step failed intermittently. Templates now build one at a time.
  • @arkstack/auth failed tsc: AuthenticationException stored a Request<unknown> in a Request<User> field, and two tests asserted on loosely typed values.
  • @arkstack/common's renderError used the view() global without a type for it.

Also included

  • 73386b9f adds inlinedDependencies to packages/common/package.json (maintainer commit that was on local main).

Test plan

  • pnpm lint, pnpm build, pnpm build:templates, pnpm docs:build
  • vitest run: 571 passed, 5 skipped
  • tsc --noEmit: 0 errors in the express, h3 and express-inertia templates and in auth, http, notifications, realtime and scheduler
  • New tests: Express/H3 after-middleware, markAllRead/unreadForUser query shape

After middleware ran on the response's finish event with the real next(), so
calling next() (as requestLogger does) resumed the router after the response
was sent and raised "Cannot set headers after they are sent to the client".
Give it a no-op next and report its errors instead of leaving them unhandled.
Add regression tests for the Express and H3 drivers.
…rPage

markAllRead() used the single-row update() and so marked only one
notification; use updateFrom(). unreadForUser(user, perPage) now passes
perPage to paginate(), and both filter unread rows with whereNull('readAt').
DotPath recursed without limit into every object, so a config holding
nodemailer transports failed to typecheck with "circularly references
itself" wherever config() was called. Bound the depth and stop at built-in
object types, and drop the @ts-expect-error workarounds this needed in the
H3 template and the notifications configure() helper.
- build:templates ran each template's prebuild in parallel, and each
  rebuilt the shared packages at once, so builds clobbered one another.
- AuthenticationException stored a Request<unknown> in a Request<User>
  field; two auth tests asserted on loosely typed values.
- renderError used the view() global, which common has no type for.
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/common/src/network.ts 0.00% 1 Missing ⚠️
packages/driver-express/src/ExpressDriver.ts 75.00% 1 Missing ⚠️
packages/http/src/Request.ts 93.33% 1 Missing ⚠️
...ckages/notifications/src/UserNotificationCenter.ts 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@3m1n3nc3
3m1n3nc3 merged commit 017af6e into main Oct 10, 2026
4 checks passed
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