Skip to content

feat(notification): add six app stop reasons - #24

Merged
qq815776412 merged 3 commits into
feat/v1.12from
feat/app-stop-reasons
Aug 10, 2026
Merged

feat(notification): add six app stop reasons#24
qq815776412 merged 3 commits into
feat/v1.12from
feat/app-stop-reasons

Conversation

@qq815776412

Copy link
Copy Markdown
Member

Summary

Apps that stop because they cannot be scheduled, or because the node is under disk / CPU / memory pressure, currently fall through to the stopped_unknown_v3 template and tell the user nothing useful. This adds a dedicated reason and notification for each case:

Reason from the application event Template
Unschedulable stopped_unschedulable_v3
DiskPressure stopped_disk_pressure_v3
SystemCPUPressure stopped_system_cpu_pressure_v3
SystemMemoryPressure stopped_system_memory_pressure_v3
K8sRequestCPUPressure stopped_k8s_request_cpu_pressure_v3
K8sRequestMemoryPressure stopped_k8s_request_memory_pressure_v3

Each template is seeded in all seven supported languages (en-US, zh-CN, de-DE, es-ES, fr-FR, it-IT, ja-JP) and follows the wording of the existing stop templates. PrismaService.updateTemplateList() creates them on startup and leaves existing templates untouched, so no migration is needed.

The reason mapping also moved out of the if / else if chain in UsersService into a lookup table in a new dependency-free stop-reason module. Adding a reason is now a single entry, and the mapping can be imported by tests without pulling in @bytetrade/core.

Test plan

  • npm test passes (45 tests)
  • New stop-reason.spec.ts covers the mapping, the fallback to stopped_unknown_v3 for an unmapped reason, and that every mapped template id actually exists in the seeds with all seven languages and a {{title}} variable. This last check matters because natsClientPublish drops a notification silently when the template is missing.
  • Verified the spec is not passing vacuously: renaming one template id in the lookup table makes it fail
  • npx tsc --noEmit passes

Note on the test setup

The published @bytetrade/core bundle contains an empty identifier (var = (autoFunc, ...) => ...) and cannot be parsed by Node, which is why the existing template.service.spec.ts had not been runnable. Tests now map the package to a small stub, so that suite runs again as well. The same bad bundle still breaks npm run build under webpack; that is pre-existing and out of scope here.

Made with Cursor

qq815776412 and others added 3 commits July 30, 2026 22:16
Notify users when an app is stopped because it cannot be scheduled or
because of disk, CPU or memory pressure, so a stop no longer surfaces as
"unknown". Adds Unschedulable, DiskPressure, SystemCPUPressure,
SystemMemoryPressure, K8sRequestCPUPressure and K8sRequestMemoryPressure
with templates in all seven supported languages.

Replace the reason if-else chain with a lookup table in a dependency-free
module so adding a reason is a single entry and the mapping can be tested
without loading @bytetrade/core, whose published bundle fails to parse.
A reason whose template is missing from the seeds is dropped silently, so
the new spec asserts the mapping and the seeds stay in agreement.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants