Skip to content

Erroor boundaries - #1

Closed
megothss wants to merge 12 commits into
mainfrom
erroor-boundaries
Closed

megothss wants to merge 12 commits into
mainfrom
erroor-boundaries

Conversation

@megothss

@megothss megothss commented Mar 4, 2026

Copy link
Copy Markdown
Owner

No description provided.

@github-actions

github-actions Bot commented Mar 4, 2026 •

Copy link
Copy Markdown

📊 Package size report   1%↑

File Before (Size / Brotli) After (Size / Brotli)
Total (Includes all files) 17.1 MB / 3.2 MB 1%↑17.3 MB / 1%↑3.2 MB
Tarball size 3.8 MB 1%↑3.9 MB
Show files (28 files)
File Before (Size / Brotli) After (Size / Brotli)
dist/ember-template-compiler.js 767.5 kB / 114.2 kB 0.09%↑768.1 kB / 0.2%↑114.3 kB
dist/ember-template-compiler.js.map 1.5 MB / 260.1 kB 0.2%↑1.5 MB / 0.3%↑260.8 kB
dist/ember.debug.js 2.1 MB / 321.9 kB 1%↑2.1 MB / 2%↑326.9 kB
dist/ember.debug.js.map 3.4 MB / 634.6 kB 1%↑3.5 MB / 1%↑642.6 kB
dist/ember.prod.js 1.9 MB / 292.6 kB 2%↑1.9 MB / 2%↑297.2 kB
dist/ember.prod.js.map 3.3 MB / 607.7 kB 1%↑3.3 MB / 1%↑615.5 kB
dist/packages/@glimmer/validator/index.js 40.8 kB / 8.8 kB 5%↑42.6 kB / 6%↑9.3 kB
dist/packages/ember-template-compiler/index.js 467.4 kB / 92.5 kB 0.1%↑467.9 kB / 0.2%↑92.6 kB
dist/packages/shared-chunks/api-BjZSH3SC.js 10.2 kB / 2.2 kB 2%↑10.4 kB / 8%↑2.3 kB
dist/packages/shared-chunks/capabilities-G1QB3ga_.js 32.2 kB / 7.8 kB 0.4%↑32.4 kB / 0.4%↑7.8 kB
dist/packages/shared-chunks/dynamic-DGftgZH8.js 118 kB / 23.8 kB —
dist/packages/shared-chunks/element-builder-4PkjBn66.js 11.7 kB / 2.6 kB —
dist/packages/shared-chunks/index-BGP1rw3B.js 189 kB / 40.9 kB 1%↑191.5 kB / 1%↑41.4 kB
dist/packages/shared-chunks/on-B88ZzAuo.js — 152.6 kB / 30.7 kB
dist/packages/shared-chunks/render-KwupVVPY.js 38.7 kB / 8.4 kB -10.2%↓34.7 kB / -4.96%↓8 kB
types/stable/@ember/-internals/glimmer/index.d.ts 14.1 kB / 3.1 kB 0.7%↑14.2 kB / 0.6%↑3.1 kB
types/stable/@ember/-internals/glimmer/lib/components/error-boundary.d.ts — 169 B / 132 B
types/stable/@ember/-internals/glimmer/lib/templates/error-boundary.d.ts — 171 B / 116 B
types/stable/@glimmer/interfaces/lib/dom/attributes.d.ts 4.8 kB / 1.2 kB 3%↑5 kB / 4%↑1.3 kB
types/stable/@glimmer/interfaces/lib/managers/internal/component.d.ts 12.1 kB / 2.5 kB 2%↑12.4 kB / 3%↑2.6 kB
types/stable/@glimmer/interfaces/lib/runtime/debug-render-tree.d.ts 1.4 kB / 407 B 19%↑1.6 kB / 20%↑490 B
types/stable/@glimmer/runtime/index.d.ts 2.6 kB / 753 B 5%↑2.8 kB / 3%↑776 B
types/stable/@glimmer/runtime/lib/component/error-boundary.d.ts — 1.2 kB / 425 B
types/stable/@glimmer/runtime/lib/vm/append.d.ts 11.9 kB / 2.2 kB 3%↑12.3 kB / 6%↑2.4 kB
types/stable/@glimmer/runtime/lib/vm/element-builder.d.ts 6.3 kB / 1.3 kB 15%↑7.3 kB / 23%↑1.6 kB
types/stable/@glimmer/runtime/lib/vm/update.d.ts 3.1 kB / 775 B 29%↑4 kB / 25%↑970 B
types/stable/@glimmer/validator/lib/tracking.d.ts 925 B / 336 B 108%↑1.9 kB / 96%↑657 B
types/stable/index.d.ts 43.9 kB / 4.1 kB 0.6%↑44.1 kB / 0.6%↑4.1 kB

🤖 This report was automatically generated by pkg-size-action

megothss added 9 commits March 4, 2026 22:40
…ntegration tests

Fixes the updating opcode integration so ErrorBoundaryOpcode is properly
placed in the parent VM's updating list (not pushed onto the stack where
it gets lost). Adds JS exception handling in UpdatingVM._execute with
tracking frame rollback, executeGuarded() for sub-VM isolation, debug
render tree rollback, and backflow assertion bypass in setError().
Includes 7 integration tests covering initial render, rerender, retry,
nested boundaries, and missing error block.
Cache DOM boundaries before child opcodes execute so error recovery can
clean up correctly even when inner TryOpcodes corrupt the bounds tree.
Add beginBlock nextSibling parameter for proper insertion positioning.
Add comprehensive integration tests for error boundary edge cases.
…OM refs

Replace try-catch in evaluate() with unconditional snapshot + debug assertion,
since bounds are always initialized. Null out cached DOM references after error
recovery to avoid retaining detached nodes.
…ge.json

The ember-template-compiler/index.js exposed dependency mapping was
unintentionally removed in an earlier commit.
Replace vm.execute() with vm.executeGuarded() in nested VM contexts to
prevent resetTracking() from destroying parent tracking frames. In DEBUG
mode, AppendingVM.execute() calls resetTracking() on error, which wipes
ALL tracking state including the parent UpdatingVM's frames. This made
ErrorBoundary recovery impossible and caused "attempted to close a
tracking frame" crashes.

Fixes:
- Backtracking assertions on tracked mutation after error recovery
- Double-trigger tracking frame corruption (error → error → retry)
- Error-in-error-block rendering failures bubbling incorrectly
- ListBlockOpcode.insertItem tracking corruption when new items throw

Changes:
- TryOpcode.handleException(): use executeGuarded() so errors propagate
  cleanly to the UpdatingVM's catch handler without wiping tracking state
- ErrorBoundaryOpcode.handleException(): restore tracking before re-render,
  use executeGuarded(), add robust DOM cleanup with lastPreviousSibling
  fallback for when inner TryOpcodes detach cached nodes via bounds.reset()
- ErrorBoundaryOpcode.handleError(): restore tracking and consumed tags
  before transitioning to error state
- ErrorBoundaryOpcode.transitionToError(): use executeGuarded(), add
  previousSibling-based DOM cleanup fallback, roll back debug render tree
- ListBlockOpcode.insertItem(): use executeGuarded()
- Add resetConsumedTags() to debug.ts to discard stale CONSUMED_TAGS
  entries after popping tracking frames during error recovery

Adjusts assertion count in "readable error stack" test (7→6): the single
outer console.error from UpdatingVM.execute() now captures full tracking
info since the inner call no longer prematurely wipes it.

Adds 5 regression tests covering all fix scenarios.
- Add handleError() to ExceptionHandler interface, removing unsafe `any`
  casts in UpdatingVMFrame.handleError()
- Cast tagFor() results to UpdatableTag in ErrorBoundaryState.setError()
  to satisfy dirtyTag() parameter type
- Cast array access in restoreTrackingTo() to fix Tracker | undefined
  not assignable to Tracker | null
- Extract inline decorated class in test to fix "decorators are not
  valid here" TS error
- Change defineSimpleHelper param from boolean to unknown to match
  expected signature
- Remove unused imports (destroyChildren, clear) from component.ts
- Run prettier on all modified files
ErrorBoundary should only be importable from @ember/component, matching
the pattern of Input and Textarea. The value re-export was pulling 51
source files into type-tests compilation, causing 349 type errors.
@megothss
megothss force-pushed the erroor-boundaries branch from 597fa95 to 626cf13 Compare March 5, 2026 16:14
megothss added 3 commits March 5, 2026 13:46
The console.error logging is guarded by DEBUG in the source, so these
tests can't pass in production builds.
A single modifier throwing during transaction.commit() previously aborted
the entire loop, leaving all subsequently-scheduled modifiers uninstalled.
Wrap each install/update in try-catch, collect the first error, and
re-throw after all modifiers have been processed.
@megothss megothss closed this Mar 6, 2026
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