Skip to content

Commit

Permalink
refactor: simplify date calculation and remove date-fns dependency (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Sep 24, 2024
1 parent bbdc43a commit 638a550
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-insects-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

refactor: simplify date calculation and remove date-fns dependency
1 change: 0 additions & 1 deletion packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"blake3-wasm": "^2.1.5",
"chokidar": "^3.5.3",
"date-fns": "^3.6.0",
"esbuild": "0.17.19",
"miniflare": "workspace:*",
"nanoid": "^3.3.3",
Expand Down
5 changes: 2 additions & 3 deletions packages/wrangler/src/dev-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import net from "node:net";
import path from "node:path";
import bodyParser from "body-parser";
import { watch } from "chokidar";
import { subMinutes } from "date-fns";
import express from "express";
import { createHttpTerminator } from "http-terminator";
import { fetch } from "undici";
Expand Down Expand Up @@ -75,8 +74,8 @@ async function loadWorkerDefinitions(): Promise<WorkerRegistry> {
"utf8"
);
const stats = await stat(path.join(DEV_REGISTRY_PATH, workerName));
// Cleanup old workers
if (stats.mtime < subMinutes(new Date(), 10)) {
// Cleanup existing workers older than 10 minutes
if (stats.mtime.getTime() < Date.now() - 600000) {
await unregisterWorker(workerName);
} else {
globalWorkers[workerName] = JSON.parse(file);
Expand Down
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 638a550

Please sign in to comment.