chore: bug fixes and code quality improvements#19
Merged
Conversation
push1kb
commented
Mar 1, 2026
Owner
- Re-queue logs back into batch on flush failure instead of discarding (closes #1)
- Add 30s AbortController timeout to all fetch requests (closes #5)
- Transport now throws after retries are exhausted so flush can catch and re-queue
- 4xx client errors (except 429) return without throwing since they aren't retryable
- Remove isDebug from transport (always gzip)
- Use isDev() helper consistently for dev-only warnings
- Update tests for new throw-on-exhaustion behavior and AbortSignal
- Re-queue logs back into batch on flush failure instead of discarding (closes #1) - Add 30s AbortController timeout to all fetch requests (closes #5) - Transport now throws after retries are exhausted so flush can catch and re-queue - 4xx client errors (except 429) return without throwing since they aren't retryable - Remove isDebug from transport (always gzip) - Use isDev() helper consistently for dev-only warnings - Update tests for new throw-on-exhaustion behavior and AbortSignal
- Re-queue failed logs on flush failure instead of discarding (#1) - Add 30s AbortController timeout to all fetch requests (#5) - Add destroyed state guard — log() no-ops after destroy() (#12) - Validate batchSize >= 1 and flushInterval >= 100ms (#6) - Fix README log() examples to match actual API signature (#4) - Remove unused LogEntry export and dead mocks.ts (#15, #16) - Document built-in error handler bucket names in README (#13) - Clear user/session internally on destroy() (#11) - Add buckets and fetch to README options list (#10) - Add engines field requiring Node.js >= 18 (#8) - Add changelog at docs/changelog-v0.1.1.md
Add five reliability improvements to @gunsole/core: - Edge runtime support: fall back to globalThis.fetch for Cloudflare Workers, Deno, and Bun environments - BigInt safety: serialize BigInt values in log context to strings instead of throwing on JSON.stringify - Backoff jitter: add ±50% random jitter to retry delays to prevent thundering herd on concurrent failures - Queue size cap: new maxQueueSize config (default 1000) drops oldest entries when exceeded, preventing OOM under sustained logging - Retry cap: drop log entries after 10 failed flush attempts and strip internal _flushAttempts field from sent payloads
- implement SDK gaps for debug toggle, hooks, rate limiting, and versioning - Add isDestroyed getter, runtime debug mode toggle (setDebug), beforeSend hook, lifecycle hooks (onLog/onFlush/onError), token-bucket rate limiting, per-call userId override, auto-generated sessionId, HTTP 413 split-and-retry, SDK version header (X-Gunsole-SDK-Version), sideEffects: false, and .d.cts type declarations.
Browser-specific utilities that extend @gunsole/core: - sendBeacon on pagehide for zero data loss - online/offline network awareness - fetch keepalive for small payloads (<51KB) - URL/localStorage debug toggle - visibility-change flush - re-init guard
Expose read-only getters and drainBatch() needed by @gunsole/web for sendBeacon support. Reserve new accessor names in bucket validation.
Re-export createGunsoleClient from @gunsole/web with keepalive fetch, web lifecycle, global error handlers, and session ID baked in. Removed @gunsole/core direct dependency from demo apps.
Core: - Fix config.sessionId passthrough (was silently dropped by normalizeConfig) - Constructor now uses config.sessionId ?? crypto.randomUUID() - Add fatal log level, fatal() method, and fatal bucket logger - Add getSessionId() accessor - Add createGunsole/createGunsoleServer/createGunsoleWeb aliases Web: - Add persistSession() utility for cookie-based session persistence - Export GUNSOLE_SESSION_COOKIE constant Next.js app: - Add server-side logging with @gunsole/core (SSR + API routes) - Shared config, client/server helpers with session cookie bridge - Pokemon search now proxies through /api/pokemon/[name] route - Add error.tsx with fatal logging All apps: - Add fatal error handling (React/Solid via TanStack errorComponent, Angular via ErrorHandler, Next.js via error.tsx) - Trigger Error button now throws real errors
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.