Skip to content

chore: bug fixes and code quality improvements#19

Merged
push1kb merged 14 commits into
mainfrom
push1kb/bug-fixes-v01
Mar 8, 2026
Merged

chore: bug fixes and code quality improvements#19
push1kb merged 14 commits into
mainfrom
push1kb/bug-fixes-v01

Conversation

@push1kb

@push1kb push1kb commented Mar 1, 2026

Copy link
Copy Markdown
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

push1kb added 14 commits March 1, 2026 11:15
- 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
@push1kb
push1kb merged commit 7bb0c54 into main Mar 8, 2026
2 checks passed
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