debug: fetch.worker, sqlite.worker

This commit is contained in:
Alex Gleason 2023-12-27 16:59:06 -06:00
parent 520c35db60
commit 667d00bbd0
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 7 additions and 2 deletions

View File

@ -1,13 +1,16 @@
import { Comlink } from '@/deps.ts';
import { Comlink, Debug } from '@/deps.ts';
import './handlers/abortsignal.ts';
const debug = Debug('ditto:fetch.worker');
export const FetchWorker = {
async fetch(
url: string,
init: Omit<RequestInit, 'signal'>,
signal: AbortSignal | null | undefined,
): Promise<[BodyInit, ResponseInit]> {
debug(init.method, url);
const response = await fetch(url, { ...init, signal });
return [
await response.arrayBuffer(),

View File

@ -1,9 +1,10 @@
/// <reference lib="webworker" />
import { Comlink, type CompiledQuery, DenoSqlite3, type QueryResult, Sentry } from '@/deps.ts';
import { Comlink, type CompiledQuery, Debug, DenoSqlite3, type QueryResult, Sentry } from '@/deps.ts';
import '@/sentry.ts';
let db: DenoSqlite3 | undefined;
const debug = Debug('ditto:sqlite.worker');
export const SqliteWorker = {
open(path: string): void {
@ -11,6 +12,7 @@ export const SqliteWorker = {
},
executeQuery<R>({ sql, parameters }: CompiledQuery): QueryResult<R> {
if (!db) throw new Error('Database not open');
debug(sql);
const result: QueryResult<R> = Sentry.startSpan({ name: sql, op: 'db.query' }, () => {
return {