tldraw/tldraw
Debugging
Where to look when things go wrong.
In-editor debug tools
The SDK ships a debug panel: packages/tldraw/src/lib/ui/components/DebugMenu/. The DefaultDebugPanel (packages/tldraw/src/lib/ui/components/DefaultDebugPanel.tsx) shows when the editor is in debug mode and exposes flags. Toggle it from the UI's debug menu.
packages/editor/src/lib/components/GeometryDebuggingView.tsx renders shape geometry, snap lines, and bounds on the canvas — useful when working on hit-testing or snapping.
Logging from the editor
packages/editor/src/lib/editor/managers/PerformanceManager/ collects performance traces. packages/utils/src/lib/PerformanceTracker.ts and packages/utils/src/lib/perf.ts expose helpers used throughout the runtime. Sentry integration lives in apps/dotcom/client/sentry.client.config.ts.
Reactive bugs
Most "stale state" or "doesn't update" bugs trace back to the reactive layer:
- A component reading a value outside
useValueortrackdoesn't subscribe to it. - A computed reading state inside
unsafe__withoutCapturewon't track that read. - A side-effect that mutates within a
transactruns once at commit time, not at eachput.
The @tldraw/state README in packages/state/ covers the model. The relevant source is in packages/state/src/lib/ (Atom.ts, Computed.ts, EffectScheduler.ts, transactions.ts, capture.ts).
Migration bugs
If a record fails to load, the most common cause is a missing migration step.
- Check
packages/tlschema/src/store-migrations.tsfor store-level migrations. - Check the relevant shape's file (
packages/tlschema/src/shapes/<TLKindShape>.ts) for shape-level migrations. - Run
yarn vitest runinpackages/tlschemaand read the failure inmigrations.test.ts.
The migration framework is documented in packages/store/src/lib/migrate.ts.
Sync bugs
For multiplayer issues, the most useful files are:
packages/sync-core/src/lib/protocol.ts— wire format definitions.packages/sync-core/src/lib/TLSyncRoom.ts— server-side merge engine.packages/sync-core/src/lib/TLSyncClient.ts— client side.packages/sync-core/src/lib/ClientWebSocketAdapter.ts— reconnection and backoff.
Tests for each are alongside the source. The integration test NodeSqliteSyncWrapper.integration.test.ts exercises the persistence path end-to-end.
Failing tests
yarn vitest run --grep "<name>"to isolate.- For e2e flake,
yarn e2e-dotcom-x10runs Playwright ten times. - Snapshot mismatches: prefer regenerating with
--update-snapshotsonly when behavior intentionally changed (theAGENTS.mdrule).
TypeScript errors
- Always use
yarn typecheck(the wrapper).internal/scripts/typecheck.tsrefreshes generated assets first; baretscwill fail on missingassets/.tsbuildoutputs. - For tsserver profiling:
yarn profile-tsserver. - For compile profiling:
yarn profile-typescript.
Hot reload not working
yarn dev runs the dev servers via lazyrepo. If a package isn't rebuilding, check that:
- The package is listed in
yarn devfilters in the rootpackage.json. lazy.config.tsdeclares the right inputs/outputs for the task.
Sentry
The dotcom client (apps/dotcom/client) uses Sentry via sentry.client.config.ts. Releases are tagged using sentry-release-name.ts and sentry.properties.
Related
- Testing for test-running specifics.
- Patterns and conventions for the underlying invariants you may have violated.
- Tooling for build/lint/format errors.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.