debug: fetch.worker, sqlite.worker
This commit is contained in:
parent
520c35db60
commit
667d00bbd0
|
@ -1,13 +1,16 @@
|
||||||
import { Comlink } from '@/deps.ts';
|
import { Comlink, Debug } from '@/deps.ts';
|
||||||
|
|
||||||
import './handlers/abortsignal.ts';
|
import './handlers/abortsignal.ts';
|
||||||
|
|
||||||
|
const debug = Debug('ditto:fetch.worker');
|
||||||
|
|
||||||
export const FetchWorker = {
|
export const FetchWorker = {
|
||||||
async fetch(
|
async fetch(
|
||||||
url: string,
|
url: string,
|
||||||
init: Omit<RequestInit, 'signal'>,
|
init: Omit<RequestInit, 'signal'>,
|
||||||
signal: AbortSignal | null | undefined,
|
signal: AbortSignal | null | undefined,
|
||||||
): Promise<[BodyInit, ResponseInit]> {
|
): Promise<[BodyInit, ResponseInit]> {
|
||||||
|
debug(init.method, url);
|
||||||
const response = await fetch(url, { ...init, signal });
|
const response = await fetch(url, { ...init, signal });
|
||||||
return [
|
return [
|
||||||
await response.arrayBuffer(),
|
await response.arrayBuffer(),
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/// <reference lib="webworker" />
|
/// <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';
|
import '@/sentry.ts';
|
||||||
|
|
||||||
let db: DenoSqlite3 | undefined;
|
let db: DenoSqlite3 | undefined;
|
||||||
|
const debug = Debug('ditto:sqlite.worker');
|
||||||
|
|
||||||
export const SqliteWorker = {
|
export const SqliteWorker = {
|
||||||
open(path: string): void {
|
open(path: string): void {
|
||||||
|
@ -11,6 +12,7 @@ export const SqliteWorker = {
|
||||||
},
|
},
|
||||||
executeQuery<R>({ sql, parameters }: CompiledQuery): QueryResult<R> {
|
executeQuery<R>({ sql, parameters }: CompiledQuery): QueryResult<R> {
|
||||||
if (!db) throw new Error('Database not open');
|
if (!db) throw new Error('Database not open');
|
||||||
|
debug(sql);
|
||||||
|
|
||||||
const result: QueryResult<R> = Sentry.startSpan({ name: sql, op: 'db.query' }, () => {
|
const result: QueryResult<R> = Sentry.startSpan({ name: sql, op: 'db.query' }, () => {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue