@eik/core 2.1.69 → 2.1.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [2.1.71](https://github.com/eik-lib/core/compare/v2.1.70...v2.1.71) (2026-08-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * log ERR_STREAM_PREMATURE_CLOSE at debug level in GET handlers ([#630](https://github.com/eik-lib/core/issues/630)) ([48a303b](https://github.com/eik-lib/core/commit/48a303b8ee0d5124eb0506fefbee648f141a3507))
7
+
8
+ ## [2.1.70](https://github.com/eik-lib/core/compare/v2.1.69...v2.1.70) (2026-08-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * health check now correctly throws when file exists after deletion ([db8cf84](https://github.com/eik-lib/core/commit/db8cf84d4f905d988ed3edf9de0bc421f7419ffe))
14
+
1
15
  ## [2.1.69](https://github.com/eik-lib/core/compare/v2.1.68...v2.1.69) (2026-07-25)
2
16
 
3
17
 
@@ -1,4 +1,4 @@
1
- import mime from "mime";
1
+ import { lookup } from "mrmime";
2
2
  import path from "node:path";
3
3
  import { toUrlPathname } from "../utils/url.js";
4
4
 
@@ -26,8 +26,7 @@ const Asset = class Asset {
26
26
  org = "",
27
27
  } = {}) {
28
28
  this._mimeType =
29
- /** @type {string} */ (mime.getType(pathname)) ||
30
- "application/octet-stream";
29
+ /** @type {string} */ (lookup(pathname)) || "application/octet-stream";
31
30
  this._type = type.toLowerCase();
32
31
  this._size = -1;
33
32
 
@@ -130,10 +130,21 @@ const AliasGet = class AliasGet {
130
130
 
131
131
  const outgoingStream = outgoing.stream;
132
132
  if (outgoingStream) {
133
- outgoingStream.on("error", (err) => {
134
- this._log.info(`alias:get - File stream error - ${err}`);
135
- end({ labels: { success: false, status: 503, type } });
136
- });
133
+ outgoingStream.on(
134
+ "error",
135
+ (/** @type {NodeJS.ErrnoException} */ err) => {
136
+ // ERR_STREAM_PREMATURE_CLOSE means the client closed the
137
+ // connection before the transfer finished. This is normal
138
+ // browser behaviour (navigation, cancelled requests, etc.)
139
+ // and not a server-side error worth alerting on.
140
+ if (err.code === "ERR_STREAM_PREMATURE_CLOSE") {
141
+ this._log.debug(`alias:get - File stream error - ${err}`);
142
+ } else {
143
+ this._log.info(`alias:get - File stream error - ${err}`);
144
+ }
145
+ end({ labels: { success: false, status: 503, type } });
146
+ },
147
+ );
137
148
 
138
149
  outgoingStream.on("end", () => {
139
150
  end({ labels: { status: outgoing.statusCode, type } });
@@ -106,10 +106,21 @@ const MapGet = class MapGet {
106
106
 
107
107
  const outgoingStream = outgoing.stream;
108
108
  if (outgoingStream) {
109
- outgoingStream.on("error", (err) => {
110
- this._log.info(`map:get - File stream error - ${err}`);
111
- end({ labels: { success: false, status: 503, type: "map" } });
112
- });
109
+ outgoingStream.on(
110
+ "error",
111
+ (/** @type {NodeJS.ErrnoException} */ err) => {
112
+ // ERR_STREAM_PREMATURE_CLOSE means the client closed the
113
+ // connection before the transfer finished. This is normal
114
+ // browser behaviour (navigation, cancelled requests, etc.)
115
+ // and not a server-side error worth alerting on.
116
+ if (err.code === "ERR_STREAM_PREMATURE_CLOSE") {
117
+ this._log.debug(`map:get - File stream error - ${err}`);
118
+ } else {
119
+ this._log.info(`map:get - File stream error - ${err}`);
120
+ }
121
+ end({ labels: { success: false, status: 503, type: "map" } });
122
+ },
123
+ );
113
124
 
114
125
  outgoingStream.on("end", () => {
115
126
  end({ labels: { status: outgoing.statusCode, type: "map" } });
@@ -117,10 +117,21 @@ const PkgGet = class PkgGet {
117
117
 
118
118
  const outgoingStream = outgoing.stream;
119
119
  if (outgoingStream) {
120
- outgoingStream.on("error", (err) => {
121
- this._log.info(`pkg:get - File stream error - ${err}`);
122
- end({ labels: { success: false, status: 503, type } });
123
- });
120
+ outgoingStream.on(
121
+ "error",
122
+ (/** @type {NodeJS.ErrnoException} */ err) => {
123
+ // ERR_STREAM_PREMATURE_CLOSE means the client closed the
124
+ // connection before the transfer finished. This is normal
125
+ // browser behaviour (navigation, cancelled requests, etc.)
126
+ // and not a server-side error worth alerting on.
127
+ if (err.code === "ERR_STREAM_PREMATURE_CLOSE") {
128
+ this._log.debug(`pkg:get - File stream error - ${err}`);
129
+ } else {
130
+ this._log.info(`pkg:get - File stream error - ${err}`);
131
+ }
132
+ end({ labels: { success: false, status: 503, type } });
133
+ },
134
+ );
124
135
 
125
136
  outgoingStream.on("end", () => {
126
137
  end({ labels: { status: outgoing.statusCode, type } });
@@ -109,10 +109,21 @@ const PkgLog = class PkgLog {
109
109
 
110
110
  const outgoingStream = outgoing.stream;
111
111
  if (outgoingStream) {
112
- outgoingStream.on("error", (err) => {
113
- this._log.info(`pkg:log - File stream error - ${err}`);
114
- end({ labels: { success: false, status: 503, type } });
115
- });
112
+ outgoingStream.on(
113
+ "error",
114
+ (/** @type {NodeJS.ErrnoException} */ err) => {
115
+ // ERR_STREAM_PREMATURE_CLOSE means the client closed the
116
+ // connection before the transfer finished. This is normal
117
+ // browser behaviour (navigation, cancelled requests, etc.)
118
+ // and not a server-side error worth alerting on.
119
+ if (err.code === "ERR_STREAM_PREMATURE_CLOSE") {
120
+ this._log.debug(`pkg:log - File stream error - ${err}`);
121
+ } else {
122
+ this._log.info(`pkg:log - File stream error - ${err}`);
123
+ }
124
+ end({ labels: { success: false, status: 503, type } });
125
+ },
126
+ );
116
127
 
117
128
  outgoingStream.on("end", () => {
118
129
  end({ labels: { status: outgoing.statusCode, type } });
@@ -100,10 +100,21 @@ const VersionsGet = class VersionsGet {
100
100
 
101
101
  const outgoingStream = outgoing.stream;
102
102
  if (outgoingStream) {
103
- outgoingStream.on("error", (err) => {
104
- this._log.info(`pkg:latest - File stream error - ${err}`);
105
- end({ labels: { success: false, status: 503, type } });
106
- });
103
+ outgoingStream.on(
104
+ "error",
105
+ (/** @type {NodeJS.ErrnoException} */ err) => {
106
+ // ERR_STREAM_PREMATURE_CLOSE means the client closed the
107
+ // connection before the transfer finished. This is normal
108
+ // browser behaviour (navigation, cancelled requests, etc.)
109
+ // and not a server-side error worth alerting on.
110
+ if (err.code === "ERR_STREAM_PREMATURE_CLOSE") {
111
+ this._log.debug(`pkg:latest - File stream error - ${err}`);
112
+ } else {
113
+ this._log.info(`pkg:latest - File stream error - ${err}`);
114
+ }
115
+ end({ labels: { success: false, status: 503, type } });
116
+ },
117
+ );
107
118
 
108
119
  outgoingStream.on("end", () => {
109
120
  end({ labels: { status: outgoing.statusCode, type } });
package/lib/sinks/test.js CHANGED
@@ -2,7 +2,7 @@ import { Writable, Readable } from "node:stream";
2
2
  import { ReadFile } from "@eik/common";
3
3
  import Metrics from "@metrics/client";
4
4
  import Sink from "@eik/sink";
5
- import mime from "mime";
5
+ import { lookup } from "mrmime";
6
6
  import path from "node:path";
7
7
  import { toUrlPathname } from "../utils/url.js";
8
8
  import Entry from "./mem-entry.js";
@@ -48,7 +48,7 @@ export default class SinkTest extends Sink {
48
48
  */
49
49
  set(filePath, payload) {
50
50
  const pathname = toUrlPathname(path.join(this._rootPath, filePath));
51
- const mimeType = mime.getType(pathname) || "application/octet-stream";
51
+ const mimeType = lookup(pathname) || "application/octet-stream";
52
52
 
53
53
  let entry;
54
54
 
@@ -126,17 +126,23 @@ const HealthCheck = class HealthCheck {
126
126
  throw error;
127
127
  }
128
128
 
129
+ let existsAfterDeletion = false;
129
130
  try {
130
131
  await this._exist();
132
+ existsAfterDeletion = true;
133
+ } catch {
134
+ // Expected: file is gone after deletion
135
+ }
136
+
137
+ if (existsAfterDeletion) {
131
138
  this._log.warn(
132
139
  "Sink health check successfully read file after deletion. It should not. Content was probably not deleted by sink.delete().",
133
140
  );
134
- throw new Error("File exist in sink");
135
- // eslint-disable-next-line no-unused-vars
136
- } catch (error) {
137
- this._log.debug("Sink health check ended successfully. Sink is healthy");
141
+ throw new Error("File exist in sink after deletion");
138
142
  }
139
143
 
144
+ this._log.debug("Sink health check ended successfully. Sink is healthy");
145
+
140
146
  return true;
141
147
  }
142
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/core",
3
- "version": "2.1.69",
3
+ "version": "2.1.71",
4
4
  "description": "Core server package",
5
5
  "main": "lib/main.js",
6
6
  "types": "./types/main.d.ts",
@@ -37,23 +37,23 @@
37
37
  "abslog": "2.4.4",
38
38
  "busboy": "1.6.0",
39
39
  "http-errors": "2.0.1",
40
- "mime": "4.1.0",
40
+ "mrmime": "2.0.1",
41
41
  "original-url": "1.2.3",
42
42
  "semver": "7.8.5",
43
43
  "ssri": "14.0.0",
44
44
  "tar": "7.5.22"
45
45
  },
46
46
  "devDependencies": {
47
- "@eik/eslint-config": "2.0.9",
47
+ "@eik/eslint-config": "2.0.15",
48
48
  "@eik/prettier-config": "1.0.2",
49
- "@eik/semantic-release-config": "1.0.17",
49
+ "@eik/semantic-release-config": "1.0.18",
50
50
  "@eik/typescript-config": "1.0.2",
51
- "@types/readable-stream": "4.0.23",
51
+ "@types/readable-stream": "4.0.24",
52
52
  "eslint": "10.4.1",
53
53
  "mkdirp": "3.0.1",
54
- "npm-run-all2": "9.0.2",
54
+ "npm-run-all2": "9.0.3",
55
55
  "prettier": "3.8.3",
56
- "semantic-release": "25.0.3",
56
+ "semantic-release": "25.0.8",
57
57
  "typescript": "6.0.3"
58
58
  }
59
59
  }