Repository navigation
Release 0.1.1: clear errors and a minified package - #2
Merged
Merged
Conversation
Publishing moves out of ci.yml into release.yml. A version tag now runs the CI jobs through workflow_call, then checks that the tag matches the package.json version, points at a commit on main, and has a CHANGELOG section before it publishes. Prereleases such as 0.2.0-beta.1 go out under their own npm dist-tag, so the latest stable version stays the default install. After npm, the workflow opens a GitHub release with that version's changelog entry. A version already on npm is skipped instead of failing the run.
Apache-2.0 expects the NOTICE file to travel with the code, so it now ships in the npm package next to LICENSE.
Node and Bun print the source line of an error's first stack frame. For SDK errors that frame was always inside dist/, so users saw SDK code above every message. The constructor, load, refresh, get, require, has, getAll and onChange now restart the stack at the app's own call, and errors passed to onError carry no frames at all. Schema errors list one key per line under a count, followed by what to do. Values still never appear. status and requestId are only set when the server answered, so printed errors no longer show "status: undefined". issues is frozen and no longer enumerable, since the message already lists it.
Every fetch failure used to read "Couldn't reach Dopbase", with the real reason buried one or two levels down in cause. The SDK now reads the runtime's error code (Node keeps it in cause, Bun on the error) and falls back to the message text for Deno, which sets no code. TLS, refused, DNS and reset failures get their own code and a second line that says what to fix. A local TLS failure suggests http:// or NODE_EXTRA_CA_CERTS. All of them are still DopbaseNetworkError, so retries and the offline fallback behave as before. cause is now a small error with the runtime's message, name and code but no stack, so Node no longer prints the whole AggregateError chain and Bun no longer prints fetch internals. BREAKING CHANGE: refused connections, TLS failures, DNS failures and resets now use CONNECTION_REFUSED, TLS_ERROR, DNS_ERROR and CONNECTION_RESET instead of NETWORK_ERROR. Check for DopbaseNetworkError instead of matching the NETWORK_ERROR code.
The published maps embedded every TypeScript source file, and the readable dist/ let runtimes print SDK code above errors. The build is now minified with no source maps. keepNames stays on, or Node prints a renamed class next to the error name (m [DopbaseValidationError]). scripts/check-dist.mjs runs after every build and fails if dist/ holds a source map, isn't minified, or an error class lost its name in the ESM or CJS build. The packed package drops from 150 kB to about 53 kB.
The smoke checks only loaded one value. flows.mjs now runs on Node, Bun, Deno, Cloudflare workerd, Vercel Edge and Supabase, and checks the network error codes for each runtime's error shape, a 401, the schema message, and the offline fallback from a shared store. On Node, Bun and Deno it also checks that no error the app sees has a stack frame inside dist/. Run against the 0.1.0 build, these checks fail on every runtime that runs them.
Lists each DopbaseNetworkError code with what it means, notes that all but ABORTED are retried and can use the stored copy, and explains how to reach a local server with a self-signed certificate.
Adds the 0.1.1 entry and bumps the version in package.json and package-lock.json.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
When
load()failed, Node and Bun printed our own source code above the error, and the message often didn't say what went wrong. A bad certificate and a server that wasn't running both read "Couldn't reach Dopbase". This release fixes the errors and ships a minified package.dist/.TLS_ERROR,CONNECTION_REFUSED,DNS_ERRORandCONNECTION_RESET.status: undefinedandrequestId: undefined, or listissuestwice.release.yml, which runs on version tags.NOTICEships in the package.Breaking change
Refused connections, TLS failures, DNS failures and resets used to have
code: 'NETWORK_ERROR'. They now use the four codes above. They're all stillDopbaseNetworkError, so retries and the offline fallback work the same way. Code that matcheserror.code === 'NETWORK_ERROR'should checkinstanceof DopbaseNetworkErrorinstead. Any other network failure keepsNETWORK_ERROR.Before and after
Real output from the same app and fake server, with 0.1.0 and with this branch. Paths are shortened to
/app.Schema error, Node 26
Before:
After:
Self-signed certificate, Bun 1.4
Before:
After:
Server not running, Node 26
Before (41 lines, shortened):
After:
Bad option, Node 26
Before, the arrow pointed at
normalizeHostinsidedist/chunk-ZVKYVQHE.js:239. After:The package (
npm pack --dry-run).js.mapHow it works
load,refresh,get,require,has,getAllandonChangecallError.captureStackTrace(error, method)before rethrowing aDopbaseError, so the first frame is the app's call. Errors passed toonErrorhave no app call, so they carry no frames. Overwritingerror.stackas a string doesn't work: both runtimes still print the line where the error was created.reasonOf()intransport.tsfinds the runtime's code: Node keeps it incause, sometimes two levels down, and Bun puts it on the error itself. Deno sets no code, so its message text is the fallback. The newcauseis a small error with that message, name and code, and no stack.minify,keepNamesand no source maps. WithoutkeepNames, Node printedm [DopbaseValidationError].scripts/check-dist.mjsruns after every build and fails on a source map, an unminified file, or an error class that lost its name in ESM or CJS.Testing
npm run lintandnpm run typecheck: clean.npm test: 165 passed. New tests cover:TimeoutErrorSMOKE_SUPABASE=1 npm run test:runtimes: Node ESM, Node CJS,--import register, Bun, Deno, Cloudflare workerd, Vercel Edge and Supabase all pass. The newscripts/smoke/flows.mjsruns on all of them except Node CJS and--import register, and checks error codes, a 401, the schema message and the offline fallback. With the 0.1.0 build swapped in, it fails on every runtime that runs it.onChange,refresh(), schema results, every HTTP error, retries, the offline fallback, inject, and a real load. The other 20 differ only in message text, codes, the slimmercause, and the removed empty fields.Known limits
awaitstill has Node's ownrunMicrotasks()line on top. That's Node's code, and a library can't remove it.NETWORK_ERROR, as in 0.1.0.DEBUG=dopbaselogs, carry what we need.Releasing
After merge, tag
0.1.1onmainand push the tag.release.ymlchecks that the tag,package.jsonandCHANGELOG.mdagree, then publishes to npm and opens the GitHub release.