Skip to content

Commit

Permalink
Native Node Fetch (#3061)
Browse files Browse the repository at this point in the history
* Update Electron
* Drop Node Fetch
* Update Node Version
  • Loading branch information
jameskerr authored May 2, 2024
1 parent 59c4c4a commit ca047c0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.18.2
20.11.0
2 changes: 1 addition & 1 deletion apps/zui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"date-fns": "^2.16.1",
"debut-css": "^0.7.0",
"decompress": "^4.2.1",
"electron": "28.0.0",
"electron": "30.0.1",
"electron-builder": "^23.6.0",
"electron-builder-notarize": "^1.2.0",
"electron-devtools-assembler": "^1.2.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/zed-js/src/client/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export abstract class BaseClient {
headers?: Record<string, string>;
timeout?: number;
contentType?: string;
duplex?: 'half';
}) {
const abortCtl = wrapAbort(opts.signal);
const clearTimer = this.setTimeout(() => {
Expand All @@ -174,6 +175,9 @@ export abstract class BaseClient {
// eslint-disable-next-line
// @ts-ignore
body: opts.body,
// eslint-disable-next-line
// @ts-ignore
duplex: opts.duplex,
});
clearTimer();
if (resp.ok) {
Expand Down
4 changes: 1 addition & 3 deletions packages/zed-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
"exports": "./src/index.js",
"devDependencies": {
"@types/fs-extra": "^11.0.1",
"@types/node-fetch": "^2.6.2",
"zed": "github:brimdata/zed#main"
},
"dependencies": {
"@brimdata/zed-js": "workspace:*",
"fs-extra": "^11.1.1",
"node-fetch": "^2.6.2"
"fs-extra": "^11.1.1"
},
"peerDependencies": {
"zed": "*"
Expand Down
7 changes: 2 additions & 5 deletions packages/zed-node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import {
getLoadContentType,
jsonHeader,
} from '@brimdata/zed-js';
import nodeFetch from 'node-fetch';

export class Client extends BaseClient {
// eslint-disable-next-line
// @ts-ignore
// eslint-disable-next-line
public fetch = (...args: any[]) => nodeFetch(...args);
public fetch = globalThis.fetch;

async load(
data: string | NodeJS.ReadableStream,
Expand All @@ -29,6 +25,7 @@ export class Client extends BaseClient {
// eslint-disable-next-line
// @ts-ignore
body: data,
duplex: 'half',
headers,
contentType: getLoadContentType(opts.format) ?? '',
signal: opts.signal,
Expand Down
3 changes: 1 addition & 2 deletions packages/zed-node/src/lake.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChildProcess, spawn, SpawnOptions } from 'child_process';
import { mkdirpSync } from 'fs-extra';
import { join } from 'path';
import fetch from 'node-fetch';
import { getZedPath } from './binpath';

type ConstructorOpts = {
Expand Down Expand Up @@ -83,7 +82,7 @@ export class Lake {

async isUp() {
try {
const response = await fetch(`http://${this.addr()}/status`);
const response = await globalThis.fetch(`http://${this.addr()}/status`);
const text = await response.text();
return text === 'ok';
} catch (e) {
Expand Down
53 changes: 15 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1921,9 +1921,7 @@ __metadata:
dependencies:
"@brimdata/zed-js": "workspace:*"
"@types/fs-extra": ^11.0.1
"@types/node-fetch": ^2.6.2
fs-extra: ^11.1.1
node-fetch: ^2.6.2
zed: "github:brimdata/zed#main"
peerDependencies:
zed: "*"
Expand Down Expand Up @@ -5094,16 +5092,6 @@ __metadata:
languageName: node
linkType: hard

"@types/node-fetch@npm:^2.6.2":
version: 2.6.2
resolution: "@types/node-fetch@npm:2.6.2"
dependencies:
"@types/node": "*"
form-data: ^3.0.0
checksum: 6f73b1470000d303d25a6fb92875ea837a216656cb7474f66cdd67bb014aa81a5a11e7ac9c21fe19bee9ecb2ef87c1962bceeaec31386119d1ac86e4c30ad7a6
languageName: node
linkType: hard

"@types/node-fetch@npm:^3.0.3":
version: 3.0.3
resolution: "@types/node-fetch@npm:3.0.3"
Expand All @@ -5127,21 +5115,21 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^18.11.18":
version: 18.19.3
resolution: "@types/node@npm:18.19.3"
"@types/node@npm:^20.11.0":
version: 20.11.0
resolution: "@types/node@npm:20.11.0"
dependencies:
undici-types: ~5.26.4
checksum: 58c4fa45a78fcec75c78182a4b266395905957633654eb0311c5f9c30ac15c179ea2287ab1af034e46c2db7bb0589ef0000ee64c1de8f568a0aad29eaadb100c
checksum: 1bd6890db7e0404d11c33d28f46f19f73256f0ba35d19f0ef2a0faba09f366f188915fb9338eebebcc472075c1c4941e17c7002786aa69afa44980737846b200
languageName: node
linkType: hard

"@types/node@npm:^20.11.0":
version: 20.11.0
resolution: "@types/node@npm:20.11.0"
"@types/node@npm:^20.9.0":
version: 20.12.7
resolution: "@types/node@npm:20.12.7"
dependencies:
undici-types: ~5.26.4
checksum: 1bd6890db7e0404d11c33d28f46f19f73256f0ba35d19f0ef2a0faba09f366f188915fb9338eebebcc472075c1c4941e17c7002786aa69afa44980737846b200
checksum: 7cc979f7e2ca9a339ec71318c3901b9978555257929ef3666987f3e447123bc6dc92afcc89f6347e09e07d602fde7d51bcddea626c23aa2bb74aeaacfd1e1686
languageName: node
linkType: hard

Expand Down Expand Up @@ -8960,16 +8948,16 @@ __metadata:
languageName: node
linkType: hard

"electron@npm:28.0.0":
version: 28.0.0
resolution: "electron@npm:28.0.0"
"electron@npm:30.0.1":
version: 30.0.1
resolution: "electron@npm:30.0.1"
dependencies:
"@electron/get": ^2.0.0
"@types/node": ^18.11.18
"@types/node": ^20.9.0
extract-zip: ^2.0.1
bin:
electron: cli.js
checksum: 5e0da4f3a8b6746cc597b20453cec89a346c9b64b6d3e3dbc7ba015c1e7d1dcaf43c2fc7c3115fc57f68853724049a6b21e40a82becb49df2d8207cbf6cbc3ea
checksum: 3e2c587eaf74e54523db314effb6558cdbb0bc71e40bb2d1f090cbe2051ded59ee74519100e184f6a88e45dd87f14c28610cd94a25518a24513f2ca5e876eaef
languageName: node
linkType: hard

Expand Down Expand Up @@ -10164,17 +10152,6 @@ __metadata:
languageName: node
linkType: hard

"form-data@npm:^3.0.0":
version: 3.0.1
resolution: "form-data@npm:3.0.1"
dependencies:
asynckit: ^0.4.0
combined-stream: ^1.0.8
mime-types: ^2.1.12
checksum: b019e8d35c8afc14a2bd8a7a92fa4f525a4726b6d5a9740e8d2623c30e308fbb58dc8469f90415a856698933c8479b01646a9dff33c87cc4e76d72aedbbf860d
languageName: node
linkType: hard

"form-data@npm:^4.0.0":
version: 4.0.0
resolution: "form-data@npm:4.0.0"
Expand Down Expand Up @@ -14367,7 +14344,7 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:*, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.11, node-fetch@npm:^2.6.2, node-fetch@npm:^2.6.7":
"node-fetch@npm:*, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.11, node-fetch@npm:^2.6.7":
version: 2.6.11
resolution: "node-fetch@npm:2.6.11"
dependencies:
Expand Down Expand Up @@ -19336,7 +19313,7 @@ __metadata:
date-fns: ^2.16.1
debut-css: ^0.7.0
decompress: ^4.2.1
electron: 28.0.0
electron: 30.0.1
electron-builder: ^23.6.0
electron-builder-notarize: ^1.2.0
electron-devtools-assembler: ^1.2.0
Expand Down

0 comments on commit ca047c0

Please sign in to comment.