@eik/core 2.1.75 → 2.1.76
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 +7 -0
- package/lib/handlers/map.put.js +23 -12
- package/lib/handlers/pkg.put.js +24 -12
- package/package.json +1 -1
- package/types/handlers/map.put.d.ts +3 -20
- package/types/handlers/pkg.put.d.ts +3 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.1.76](https://github.com/eik-lib/core/compare/v2.1.75...v2.1.76) (2026-08-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* propagate sink errors in _readVersions rather than silently resetting version history ([#635](https://github.com/eik-lib/core/issues/635)) ([b248bb7](https://github.com/eik-lib/core/commit/b248bb7b644ccd8fb7116157c44917b1ccf7990e))
|
|
7
|
+
|
|
1
8
|
## [2.1.75](https://github.com/eik-lib/core/compare/v2.1.74...v2.1.75) (2026-08-14)
|
|
2
9
|
|
|
3
10
|
|
package/lib/handlers/map.put.js
CHANGED
|
@@ -172,25 +172,32 @@ const MapPut = class MapPut {
|
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* @param {any} incoming
|
|
175
|
+
* @returns {Promise<InstanceType<typeof Versions>>}
|
|
175
176
|
*/
|
|
176
177
|
async _readVersions(incoming) {
|
|
177
178
|
const path = createFilePathToVersion(incoming);
|
|
178
|
-
|
|
179
|
+
|
|
180
|
+
if (!this._sink) throw new Error("No sink configured");
|
|
181
|
+
|
|
179
182
|
try {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.
|
|
183
|
-
`map:put - Successfully read version meta file from sink - Pathname: ${path}`,
|
|
184
|
-
);
|
|
185
|
-
// eslint-disable-next-line no-unused-vars
|
|
186
|
-
} catch (error) {
|
|
187
|
-
// File does not exist, its probably a new package
|
|
188
|
-
versions = new Versions(incoming);
|
|
183
|
+
await this._sink.exist(path);
|
|
184
|
+
} catch {
|
|
185
|
+
// File does not exist — this is a new import map.
|
|
189
186
|
this._log.info(
|
|
190
187
|
`map:put - Version meta file did not exist in sink - Create new - Pathname: ${path}`,
|
|
191
188
|
);
|
|
189
|
+
return new Versions(incoming);
|
|
192
190
|
}
|
|
193
|
-
|
|
191
|
+
|
|
192
|
+
// File exists. Any failure here must propagate rather than be
|
|
193
|
+
// swallowed — silently falling back to an empty Versions object
|
|
194
|
+
// would cause _writeVersions to overwrite the index and erase the
|
|
195
|
+
// entire version history.
|
|
196
|
+
const obj = await readJSON(this._sink, path);
|
|
197
|
+
this._log.info(
|
|
198
|
+
`map:put - Successfully read version meta file from sink - Pathname: ${path}`,
|
|
199
|
+
);
|
|
200
|
+
return new Versions(obj);
|
|
194
201
|
}
|
|
195
202
|
|
|
196
203
|
/**
|
|
@@ -251,7 +258,11 @@ const MapPut = class MapPut {
|
|
|
251
258
|
org,
|
|
252
259
|
});
|
|
253
260
|
|
|
254
|
-
const versions = await this._readVersions(incoming)
|
|
261
|
+
const versions = await this._readVersions(incoming).catch(() => {
|
|
262
|
+
const e = new HttpError.BadGateway();
|
|
263
|
+
end({ labels: { success: false, status: e.status, type: "map" } });
|
|
264
|
+
throw e;
|
|
265
|
+
});
|
|
255
266
|
|
|
256
267
|
if (!versions.check(pVersion)) {
|
|
257
268
|
this._log.info(
|
package/lib/handlers/pkg.put.js
CHANGED
|
@@ -138,25 +138,32 @@ const PkgPut = class PkgPut {
|
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* @param {any} incoming
|
|
141
|
+
* @returns {Promise<InstanceType<typeof Versions>>}
|
|
141
142
|
*/
|
|
142
143
|
async _readVersions(incoming) {
|
|
143
144
|
const path = createFilePathToVersion(incoming);
|
|
144
|
-
|
|
145
|
+
|
|
146
|
+
if (!this._sink) throw new Error("No sink configured");
|
|
147
|
+
|
|
145
148
|
try {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.
|
|
149
|
-
`pkg:put - Successfully read version meta file from sink - Pathname: ${path}`,
|
|
150
|
-
);
|
|
151
|
-
// eslint-disable-next-line no-unused-vars
|
|
152
|
-
} catch (error) {
|
|
153
|
-
// File does not exist, its probably a new package
|
|
154
|
-
versions = new Versions(incoming);
|
|
149
|
+
await this._sink.exist(path);
|
|
150
|
+
} catch {
|
|
151
|
+
// File does not exist — this is a new package.
|
|
155
152
|
this._log.info(
|
|
156
153
|
`pkg:put - Version meta file did not exist in sink - Create new - Pathname: ${path}`,
|
|
157
154
|
);
|
|
155
|
+
return new Versions(incoming);
|
|
158
156
|
}
|
|
159
|
-
|
|
157
|
+
|
|
158
|
+
// File exists. Any failure here (GCS error, corrupt JSON, network
|
|
159
|
+
// timeout) must propagate rather than be swallowed — silently falling
|
|
160
|
+
// back to an empty Versions object would cause _writeVersions to
|
|
161
|
+
// overwrite the index and erase the entire version history.
|
|
162
|
+
const obj = await readJSON(this._sink, path);
|
|
163
|
+
this._log.info(
|
|
164
|
+
`pkg:put - Successfully read version meta file from sink - Pathname: ${path}`,
|
|
165
|
+
);
|
|
166
|
+
return new Versions(obj);
|
|
160
167
|
}
|
|
161
168
|
|
|
162
169
|
/**
|
|
@@ -251,7 +258,12 @@ const PkgPut = class PkgPut {
|
|
|
251
258
|
throw e;
|
|
252
259
|
}
|
|
253
260
|
|
|
254
|
-
const versions = await this._readVersions(incoming)
|
|
261
|
+
const versions = await this._readVersions(incoming).catch(() => {
|
|
262
|
+
const e = new HttpError.BadGateway();
|
|
263
|
+
end({ labels: { success: false, status: e.status, type } });
|
|
264
|
+
throw e;
|
|
265
|
+
});
|
|
266
|
+
|
|
255
267
|
const { pkg, eikJson } = await this._parser(incoming);
|
|
256
268
|
versions.setVersion(pVersion, pkg.integrity);
|
|
257
269
|
|
package/package.json
CHANGED
|
@@ -42,27 +42,9 @@ declare const MapPut: {
|
|
|
42
42
|
}): Promise<string>;
|
|
43
43
|
/**
|
|
44
44
|
* @param {any} incoming
|
|
45
|
+
* @returns {Promise<InstanceType<typeof Versions>>}
|
|
45
46
|
*/
|
|
46
|
-
_readVersions(incoming: any): Promise<
|
|
47
|
-
_versions: Map<any, any>;
|
|
48
|
-
_type: string;
|
|
49
|
-
_name: string;
|
|
50
|
-
_org: string;
|
|
51
|
-
get versions(): [any, any][];
|
|
52
|
-
get type(): string;
|
|
53
|
-
get name(): string;
|
|
54
|
-
get org(): string;
|
|
55
|
-
setVersion(version: string, integrity: string): void;
|
|
56
|
-
getVersion(major: number): any;
|
|
57
|
-
check(version: string): boolean;
|
|
58
|
-
toJSON(): {
|
|
59
|
-
versions: [any, any][];
|
|
60
|
-
type: string;
|
|
61
|
-
name: string;
|
|
62
|
-
org: string;
|
|
63
|
-
};
|
|
64
|
-
get [Symbol.toStringTag](): string;
|
|
65
|
-
}>;
|
|
47
|
+
_readVersions(incoming: any): Promise<InstanceType<typeof Versions>>;
|
|
66
48
|
/**
|
|
67
49
|
* @param {any} incoming
|
|
68
50
|
* @param {any} versions
|
|
@@ -102,3 +84,4 @@ declare const MapPut: {
|
|
|
102
84
|
};
|
|
103
85
|
import abslog from "abslog";
|
|
104
86
|
import Metrics from "@metrics/client";
|
|
87
|
+
import Versions from "../classes/versions.js";
|
|
@@ -78,27 +78,9 @@ declare const PkgPut: {
|
|
|
78
78
|
_writeEikJson(incoming: any, capturedEikJson: Record<string, any> | null): Promise<void>;
|
|
79
79
|
/**
|
|
80
80
|
* @param {any} incoming
|
|
81
|
+
* @returns {Promise<InstanceType<typeof Versions>>}
|
|
81
82
|
*/
|
|
82
|
-
_readVersions(incoming: any): Promise<
|
|
83
|
-
_versions: Map<any, any>;
|
|
84
|
-
_type: string;
|
|
85
|
-
_name: string;
|
|
86
|
-
_org: string;
|
|
87
|
-
get versions(): [any, any][];
|
|
88
|
-
get type(): string;
|
|
89
|
-
get name(): string;
|
|
90
|
-
get org(): string;
|
|
91
|
-
setVersion(version: string, integrity: string): void;
|
|
92
|
-
getVersion(major: number): any;
|
|
93
|
-
check(version: string): boolean;
|
|
94
|
-
toJSON(): {
|
|
95
|
-
versions: [any, any][];
|
|
96
|
-
type: string;
|
|
97
|
-
name: string;
|
|
98
|
-
org: string;
|
|
99
|
-
};
|
|
100
|
-
get [Symbol.toStringTag](): string;
|
|
101
|
-
}>;
|
|
83
|
+
_readVersions(incoming: any): Promise<InstanceType<typeof Versions>>;
|
|
102
84
|
/**
|
|
103
85
|
* @param {any} incoming
|
|
104
86
|
*/
|
|
@@ -143,3 +125,4 @@ declare const PkgPut: {
|
|
|
143
125
|
};
|
|
144
126
|
import abslog from "abslog";
|
|
145
127
|
import Metrics from "@metrics/client";
|
|
128
|
+
import Versions from "../classes/versions.js";
|