diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 19f1d80..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "typescript.tsdk": "node_modules/typescript/lib", - "deno.enable": true, - "deno.suggest.imports.hosts": { - "https://deno.land": false - } -} diff --git a/remote.ts b/remote.ts index 8b3229c..720c133 100644 --- a/remote.ts +++ b/remote.ts @@ -49,10 +49,14 @@ export class RestRemoteStorage implements KeyValueStorage { [HEADER_REQUESTER]: this.appname, }, }); + // the body is consumed here to not leak resource, but it would + // be better to consume it only when needed, once + // https://github.com/denoland/deno/issues/4735 is fixed + const text = await response.text(); if (response.headers.get(HEADER_REPLYIER) != "ok") { throw new Error("storage not compatible with tk-storage"); } else if (response.status == 200) { - return await response.text(); + return text; } else if (response.status == 404) { return null; } else { diff --git a/server.ts b/server.ts index 6c14d36..6fadaa6 100755 --- a/server.ts +++ b/server.ts @@ -56,10 +56,9 @@ export function startRestServer( return new Promise((resolve) => { const server = app.listen(port, () => { resolve({ - close: () => - new Promise((resolve, reject) => { - server.close(); - }), + close: async () => { + server.close(); + }, }); }); }); diff --git a/testing.ts b/testing.ts index ac3ab75..82066e7 100644 --- a/testing.ts +++ b/testing.ts @@ -31,7 +31,7 @@ export async function disableLocalStorage( const removed = ns["localStorage"]; delete ns["localStorage"]; try { - await body; + await body(); } finally { ns["localStorage"] = removed; }