Skip to content

Commit ee970a6

Browse files
committed
chore: removed fetch patching
1 parent 0f82b33 commit ee970a6

2 files changed

Lines changed: 1 addition & 28 deletions

File tree

demo/node.mjs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ const start = function (sqlite3) {
3131
}
3232
};
3333

34-
// Mock fetch because Emscripten's Node.js loader still uses it and it fails on file:// URLs
35-
globalThis.fetch = async (url) => {
36-
if (url.toString().endsWith('.wasm')) {
37-
const buffer = readFileSync(
38-
new URL('../dist/sqlite3.wasm', import.meta.url),
39-
);
40-
return new Response(buffer, {
41-
headers: { 'Content-Type': 'application/wasm' },
42-
});
43-
}
44-
throw new Error(`Unexpected fetch to ${url}`);
45-
};
46-
4734
log('Loading and initializing SQLite3 module...');
4835
sqlite3InitModule({
4936
print: log,

src/__tests__/sqlite3-node.test.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
import { expect, test, vi } from 'vitest';
2-
import { readFileSync } from 'node:fs';
1+
import { expect, test } from 'vitest';
32
import sqlite3InitModule from '../bin/sqlite3-node.mjs';
43

54
test('Node.js build sanity check', async () => {
6-
// Mock fetch because Emscripten's Node.js loader still uses it, and it fails on file:// URLs
7-
vi.stubGlobal('fetch', async (url) => {
8-
if (url.endsWith('.wasm')) {
9-
const buffer = readFileSync(
10-
new URL('../bin/sqlite3.wasm', import.meta.url),
11-
);
12-
return new Response(buffer, {
13-
headers: { 'Content-Type': 'application/wasm' },
14-
});
15-
}
16-
throw new Error(`Unexpected fetch to ${url}`);
17-
});
18-
195
const sqlite3 = await sqlite3InitModule();
206

217
expect(typeof sqlite3.version.libVersion).toBe('string');

0 commit comments

Comments
 (0)