Skip to content

Commit ee9e3b0

Browse files
committed
work
1 parent e3add0b commit ee9e3b0

17 files changed

Lines changed: 49 additions & 21 deletions

File tree

dist/js/client_reporter.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,19 @@ const setup = () => {
178178
// only carries the id, tab, activities and log entries.
179179
let pendingLogs = [];
180180
let pendingActivities = [];
181+
// The server answering that the endpoint does not exist means there is no
182+
// monitoring behind this origin anymore (the dev server was restarted
183+
// without it, a test server took the port): reporting stops for the rest of
184+
// this page's life rather than knocking at every heartbeat.
185+
let endpointGone = false;
181186
const post = async ({ beacon = false, closing = false } = {}) => {
182187
const logs = pendingLogs;
183188
const activities = pendingActivities;
184189
pendingLogs = [];
185190
pendingActivities = [];
191+
if (endpointGone) {
192+
return;
193+
}
186194
const payload = JSON.stringify({
187195
clientId,
188196
// The server reads browser/OS from the request headers, but a headless
@@ -201,12 +209,15 @@ const setup = () => {
201209
return;
202210
}
203211
try {
204-
await nativeFetch(REPORT_ENDPOINT, {
212+
const response = await nativeFetch(REPORT_ENDPOINT, {
205213
method: "POST",
206214
headers: { "content-type": "application/json" },
207215
body: payload,
208216
keepalive: true,
209217
});
218+
if (response.status === 404 || response.status === 405) {
219+
endpointGone = true;
220+
}
210221
} catch {
211222
// dev server gone or offline — dropping the report is acceptable.
212223
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jsenv/core",
3-
"version": "41.4.19",
3+
"version": "41.4.20",
44
"type": "module",
55
"description": "Tool to develop, test and build js projects",
66
"repository": {
@@ -78,7 +78,7 @@
7878
"@jsenv/plugin-minification": "1.7.10",
7979
"@jsenv/plugin-supervisor": "1.8.13",
8080
"@jsenv/plugin-transpilation": "1.6.1",
81-
"@jsenv/server": "17.6.2",
81+
"@jsenv/server": "17.6.3",
8282
"@jsenv/sourcemap": "1.4.2",
8383
"react-table": "7.8.0"
8484
},

packages/backend/database-manager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"dependencies": {
3232
"@jsenv/database": "0.0.15",
33-
"@jsenv/server": "17.6.2",
33+
"@jsenv/server": "17.6.3",
3434
"@jsenv/urls": "2.9.10",
3535
"@tanstack/table-core": "8.21.3",
3636
"jsonwebtoken": "9.0.3",

packages/backend/server/dist/jsenv_server.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6452,7 +6452,10 @@ It should be should be one of route.${routePropertyName}: ${availableValues.join
64526452
}
64536453
}
64546454
if (!route.matchMethod(request.method)) {
6455-
if (!route.isFallback) {
6455+
// a 405 asserts the resource exists with other methods: a route
6456+
// matching any resource ("GET *") cannot assert that, so it does
6457+
// not turn an unknown resource into a 405
6458+
if (!route.isFallback && route.resource !== "*") {
64566459
wouldHaveMatched.methodSet.add(route.method);
64576460
}
64586461
continue;

packages/backend/server/docs/handling_requests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Routes are tried in order. `fetch` can be async; returning `null` or `undefined`
3232

3333
When no route answers, the router builds the response from what almost matched:
3434

35-
- **405 Method Not Allowed** (with an `allow` header) when the resource matched routes for other methods,
35+
- **405 Method Not Allowed** (with an `allow` header) when the resource matched routes for other methods — a catch-all `*` route does not count, it says nothing about the resource,
3636
- **415 Unsupported Media Type** when a POST/PATCH/PUT route wanted another `content-type` (see `acceptedMediaTypes` below),
3737
- **406 Not Acceptable** when the route cannot produce what the request accepts (see [content negotiation](./content_negotiation.md)),
3838
- **426 Upgrade Required** for a websocket route requested without an upgrade,

packages/backend/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jsenv/server",
3-
"version": "17.6.2",
3+
"version": "17.6.3",
44
"type": "module",
55
"description": "A modern Node.js HTTP server with declarative routing, content negotiation, and WebSocket support",
66
"repository": {

packages/backend/server/src/router/router.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,10 @@ It should be should be one of route.${routePropertyName}: ${availableValues.join
355355
}
356356
}
357357
if (!route.matchMethod(request.method)) {
358-
if (!route.isFallback) {
358+
// a 405 asserts the resource exists with other methods: a route
359+
// matching any resource ("GET *") cannot assert that, so it does
360+
// not turn an unknown resource into a 405
361+
if (!route.isFallback && route.resource !== "*") {
359362
wouldHaveMatched.methodSet.add(route.method);
360363
}
361364
continue;

packages/related/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jsenv/cli",
3-
"version": "0.3.146",
3+
"version": "0.3.147",
44
"type": "module",
55
"description": "Command Line Interface for jsenv",
66
"repository": {

packages/related/cli/template-node-package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@jsenv/assert": "4.5.7",
16-
"@jsenv/core": "41.4.19",
16+
"@jsenv/core": "41.4.20",
1717
"@jsenv/eslint-config-relax": "1.9.0",
1818
"@jsenv/test": "3.7.34",
1919
"eslint": "9.39.2",

packages/related/cli/template-web-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@babel/plugin-syntax-import-attributes": "7.29.7",
1919
"@jsenv/custom-elements-redefine": "0.1.0",
2020
"@jsenv/assert": "4.5.7",
21-
"@jsenv/core": "41.4.19",
21+
"@jsenv/core": "41.4.20",
2222
"@jsenv/plugin-bundling": "2.10.18",
2323
"@jsenv/plugin-minification": "1.7.10",
2424
"@jsenv/eslint-config-relax": "1.9.0",

0 commit comments

Comments
 (0)