@teambit/objects 0.0.0-85e7bed641b09ff1080a0cd55e300cbb76607d83 → 0.0.0-87722eae60f4d4be4fea8a9a6ebacae673140534
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/dist/models/model-component.js +22 -2
- package/dist/models/model-component.js.map +1 -1
- package/dist/models/version.js +1 -10
- package/dist/models/version.js.map +1 -1
- package/dist/models/version.spec.js +4 -12
- package/dist/models/version.spec.js.map +1 -1
- package/dist/objects/object-list.d.ts +6 -0
- package/dist/objects/object-list.js +47 -4
- package/dist/objects/object-list.js.map +1 -1
- package/dist/objects/repository.js +9 -2
- package/dist/objects/repository.js.map +1 -1
- package/models/model-component.ts +23 -2
- package/models/version.spec.ts +4 -12
- package/models/version.ts +1 -9
- package/objects/object-list.ts +53 -5
- package/objects/repository.ts +2 -1
- package/package.json +29 -28
- /package/dist/{preview-1758137614741.js → preview-1765229799842.js} +0 -0
package/objects/object-list.ts
CHANGED
|
@@ -2,6 +2,7 @@ import tarStream from 'tar-stream';
|
|
|
2
2
|
import { pMapPool } from '@teambit/toolbox.promise.map-pool';
|
|
3
3
|
import { compact } from 'lodash';
|
|
4
4
|
import { Readable, PassThrough, pipeline } from 'stream';
|
|
5
|
+
import crypto from 'crypto';
|
|
5
6
|
import BitObject from './object';
|
|
6
7
|
import { BitObjectList } from './bit-object-list';
|
|
7
8
|
import Ref from './ref';
|
|
@@ -52,6 +53,19 @@ export class ObjectList {
|
|
|
52
53
|
return this.objects.length;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Generates a SHA1 hash from all object buffers.
|
|
58
|
+
* Used to identify duplicate export requests during retries.
|
|
59
|
+
* Performance wise, it's not too bad. ~98ms for 150 components on CircleCI.
|
|
60
|
+
*/
|
|
61
|
+
getSha1Hash(): string {
|
|
62
|
+
const hash = crypto.createHash('sha1');
|
|
63
|
+
for (const obj of this.objects) {
|
|
64
|
+
hash.update(new Uint8Array(obj.buffer));
|
|
65
|
+
}
|
|
66
|
+
return hash.digest('hex');
|
|
67
|
+
}
|
|
68
|
+
|
|
55
69
|
static mergeMultipleInstances(objectLists: ObjectList[]): ObjectList {
|
|
56
70
|
const objectList = new ObjectList();
|
|
57
71
|
objectLists.forEach((objList) => objectList.mergeObjectList(objList));
|
|
@@ -120,7 +134,10 @@ export class ObjectList {
|
|
|
120
134
|
const extract = tarStream.extract();
|
|
121
135
|
let startData: StartFile | undefined;
|
|
122
136
|
let endData: EndFile | undefined;
|
|
137
|
+
let entriesReceived = 0;
|
|
138
|
+
|
|
123
139
|
extract.on('entry', (header, stream, next) => {
|
|
140
|
+
entriesReceived += 1;
|
|
124
141
|
const data: Buffer[] = [];
|
|
125
142
|
stream.on('data', (chunk) => {
|
|
126
143
|
data.push(chunk);
|
|
@@ -154,24 +171,40 @@ export class ObjectList {
|
|
|
154
171
|
});
|
|
155
172
|
|
|
156
173
|
// not sure if needed
|
|
157
|
-
extract.on('error', (err) => {
|
|
158
|
-
|
|
174
|
+
extract.on('error', (err: any) => {
|
|
175
|
+
logger.error(`fromTarToObjectStream tar extraction error after receiving ${entriesReceived} entries`, err);
|
|
176
|
+
|
|
177
|
+
// Enhanced error message for tar corruption with entry count
|
|
178
|
+
if (err.message?.includes('invalid tar header') || err.message?.includes('Invalid tar header')) {
|
|
179
|
+
const enhancedError = new Error(
|
|
180
|
+
`Invalid tar header after receiving ${entriesReceived} entries. Possible causes: 1) Server aborted request mid-stream, 2) Network corruption during transfer. Original error: ${err.message}`
|
|
181
|
+
);
|
|
182
|
+
enhancedError.stack = err.stack;
|
|
183
|
+
passThrough.emit('error', enhancedError);
|
|
184
|
+
} else {
|
|
185
|
+
passThrough.emit('error', err);
|
|
186
|
+
}
|
|
159
187
|
});
|
|
160
188
|
|
|
161
189
|
extract.on('finish', () => {
|
|
162
190
|
if (startData?.schema === OBJECT_LIST_CURRENT_SCHEMA && !endData) {
|
|
163
191
|
// wasn't able to find a better way to indicate whether the server aborted the request
|
|
164
192
|
// see https://github.com/node-fetch/node-fetch/issues/1117
|
|
193
|
+
logger.error(
|
|
194
|
+
`fromTarToObjectStream, server terminated the stream unexpectedly. Start: ${JSON.stringify(startData)}, entries received: ${entriesReceived}`
|
|
195
|
+
);
|
|
165
196
|
passThrough.emit(
|
|
166
197
|
'error',
|
|
167
|
-
new Error(
|
|
198
|
+
new Error(
|
|
199
|
+
`server terminated the stream unexpectedly (metadata: ${JSON.stringify(startData)}, entries received: ${entriesReceived})`
|
|
200
|
+
)
|
|
168
201
|
);
|
|
169
202
|
}
|
|
170
203
|
passThrough.end();
|
|
171
204
|
});
|
|
172
205
|
pipeline(packStream, extract, (err) => {
|
|
173
206
|
if (err) {
|
|
174
|
-
logger.error(
|
|
207
|
+
logger.error(`fromTarToObjectStream, pipeline error after ${entriesReceived} entries`, err);
|
|
175
208
|
passThrough.emit('error', err);
|
|
176
209
|
} else {
|
|
177
210
|
logger.debug('fromTarToObjectStream, pipeline is completed');
|
|
@@ -187,19 +220,34 @@ export class ObjectList {
|
|
|
187
220
|
logger.debug('fromObjectStreamToTar, start sending data', startFile);
|
|
188
221
|
pack.entry({ name: TAR_STREAM_START_FILENAME }, JSON.stringify(startFile));
|
|
189
222
|
let numOfFiles = 0;
|
|
223
|
+
let isFinalized = false;
|
|
224
|
+
|
|
190
225
|
readable.on('data', (obj: ObjectItem) => {
|
|
191
226
|
numOfFiles += 1;
|
|
192
227
|
pack.entry({ name: ObjectList.combineScopeAndHash(obj) }, obj.buffer);
|
|
193
228
|
});
|
|
194
229
|
readable.on('end', () => {
|
|
230
|
+
if (isFinalized) {
|
|
231
|
+
logger.warn(`fromObjectStreamToTar (${scopeName}), received 'end' event but pack already finalized`);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
isFinalized = true;
|
|
195
235
|
const endFile: EndFile = { numOfFiles, scopeName };
|
|
196
236
|
logger.debug('fromObjectStreamToTar, finished sending data', endFile);
|
|
197
237
|
pack.entry({ name: TAR_STREAM_END_FILENAME }, JSON.stringify(endFile));
|
|
198
238
|
pack.finalize();
|
|
199
239
|
});
|
|
200
240
|
readable.on('error', (err) => {
|
|
241
|
+
if (isFinalized) {
|
|
242
|
+
logger.error(
|
|
243
|
+
`ObjectList.fromObjectStreamToTar, received error but pack already finalized. Files sent: ${numOfFiles}`,
|
|
244
|
+
err
|
|
245
|
+
);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
isFinalized = true;
|
|
201
249
|
const errorMessage = err.message || `unexpected error (${err.name})`;
|
|
202
|
-
logger.error(`ObjectList.fromObjectStreamToTar, streaming an error as a file`, err);
|
|
250
|
+
logger.error(`ObjectList.fromObjectStreamToTar, streaming an error as a file after ${numOfFiles} files`, err);
|
|
203
251
|
pack.entry({ name: TAR_STREAM_ERROR_FILENAME }, errorMessage);
|
|
204
252
|
pack.finalize();
|
|
205
253
|
});
|
package/objects/repository.ts
CHANGED
|
@@ -10,7 +10,8 @@ import { pMapPool } from '@teambit/toolbox.promise.map-pool';
|
|
|
10
10
|
import { OBJECTS_DIR } from '@teambit/legacy.constants';
|
|
11
11
|
import { logger } from '@teambit/legacy.logger';
|
|
12
12
|
import type { ChownOptions, PathOsBasedAbsolute } from '@teambit/legacy.utils';
|
|
13
|
-
import {
|
|
13
|
+
import { writeFile } from '@teambit/legacy.utils';
|
|
14
|
+
import { glob } from 'glob';
|
|
14
15
|
import { removeEmptyDir } from '@teambit/toolbox.fs.remove-empty-dir';
|
|
15
16
|
import { concurrentIOLimit } from '@teambit/harmony.modules.concurrency';
|
|
16
17
|
import type { Types, ScopeJson } from '@teambit/legacy.scope';
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/objects",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-87722eae60f4d4be4fea8a9a6ebacae673140534",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/scope/objects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.scope",
|
|
8
8
|
"name": "objects",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "87722eae60f4d4be4fea8a9a6ebacae673140534"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@pnpm/dependency-path": "1001.1.
|
|
13
|
-
"@pnpm/lockfile.types": "^1002.0.
|
|
12
|
+
"@pnpm/dependency-path": "1001.1.6",
|
|
13
|
+
"@pnpm/lockfile.types": "^1002.0.5",
|
|
14
14
|
"semver": "7.7.1",
|
|
15
15
|
"lodash": "4.17.21",
|
|
16
16
|
"uuid": "8.3.2",
|
|
@@ -18,45 +18,46 @@
|
|
|
18
18
|
"p-map-series": "2.1.0",
|
|
19
19
|
"tar-stream": "2.2.0",
|
|
20
20
|
"fs-extra": "10.0.0",
|
|
21
|
+
"glob": "13.0.0",
|
|
21
22
|
"uid-number": "0.0.6",
|
|
22
23
|
"@teambit/harmony": "0.4.7",
|
|
23
|
-
"@teambit/cli": "0.0.
|
|
24
|
+
"@teambit/cli": "0.0.1290",
|
|
24
25
|
"@teambit/component-id": "1.2.4",
|
|
25
|
-
"@teambit/legacy.utils": "0.0.
|
|
26
|
-
"@teambit/harmony.modules.get-basic-log": "0.0.
|
|
26
|
+
"@teambit/legacy.utils": "0.0.30",
|
|
27
|
+
"@teambit/harmony.modules.get-basic-log": "0.0.91",
|
|
27
28
|
"@teambit/bit-error": "0.0.404",
|
|
28
29
|
"@teambit/component-version": "1.0.4",
|
|
29
|
-
"@teambit/component.snap-distance": "0.0.
|
|
30
|
-
"@teambit/config-store": "0.0.
|
|
30
|
+
"@teambit/component.snap-distance": "0.0.91",
|
|
31
|
+
"@teambit/config-store": "0.0.170",
|
|
31
32
|
"@teambit/lane-id": "0.0.312",
|
|
32
|
-
"@teambit/legacy.cli.error": "0.0.
|
|
33
|
-
"@teambit/legacy.constants": "0.0.
|
|
34
|
-
"@teambit/legacy.logger": "0.0.
|
|
35
|
-
"@teambit/legacy.scope": "0.0.
|
|
36
|
-
"@teambit/toolbox.crypto.sha1": "0.0.
|
|
37
|
-
"@teambit/component.sources": "0.0.
|
|
33
|
+
"@teambit/legacy.cli.error": "0.0.31",
|
|
34
|
+
"@teambit/legacy.constants": "0.0.20",
|
|
35
|
+
"@teambit/legacy.logger": "0.0.31",
|
|
36
|
+
"@teambit/legacy.scope": "0.0.90",
|
|
37
|
+
"@teambit/toolbox.crypto.sha1": "0.0.11",
|
|
38
|
+
"@teambit/component.sources": "0.0.142",
|
|
38
39
|
"@teambit/legacy-bit-id": "1.1.3",
|
|
39
|
-
"@teambit/legacy-component-log": "0.0.
|
|
40
|
-
"@teambit/legacy.consumer-component": "0.0.
|
|
41
|
-
"@teambit/legacy.consumer-config": "0.0.
|
|
42
|
-
"@teambit/legacy.extension-data": "0.0.
|
|
43
|
-
"@teambit/pkg.modules.semver-helper": "0.0.
|
|
40
|
+
"@teambit/legacy-component-log": "0.0.413",
|
|
41
|
+
"@teambit/legacy.consumer-component": "0.0.91",
|
|
42
|
+
"@teambit/legacy.consumer-config": "0.0.90",
|
|
43
|
+
"@teambit/legacy.extension-data": "0.0.92",
|
|
44
|
+
"@teambit/pkg.modules.semver-helper": "0.0.18",
|
|
44
45
|
"@teambit/toolbox.array.duplications-finder": "0.0.3",
|
|
45
46
|
"@teambit/graph.cleargraph": "0.0.11",
|
|
46
|
-
"@teambit/bit.get-bit-version": "0.0.
|
|
47
|
-
"@teambit/semantics.doc-parser": "0.0.
|
|
48
|
-
"@teambit/harmony.modules.concurrency": "0.0.
|
|
49
|
-
"@teambit/toolbox.promise.map-pool": "0.0.
|
|
50
|
-
"@teambit/harmony.modules.in-memory-cache": "0.0.
|
|
51
|
-
"@teambit/toolbox.fs.remove-empty-dir": "0.0.
|
|
52
|
-
"@teambit/graph": "0.0.0-
|
|
47
|
+
"@teambit/bit.get-bit-version": "0.0.11",
|
|
48
|
+
"@teambit/semantics.doc-parser": "0.0.98",
|
|
49
|
+
"@teambit/harmony.modules.concurrency": "0.0.21",
|
|
50
|
+
"@teambit/toolbox.promise.map-pool": "0.0.10",
|
|
51
|
+
"@teambit/harmony.modules.in-memory-cache": "0.0.24",
|
|
52
|
+
"@teambit/toolbox.fs.remove-empty-dir": "0.0.9",
|
|
53
|
+
"@teambit/graph": "0.0.0-bd99e08f4df12bb87883e301c2d192c94b2c1d1e"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@types/semver": "7.5.8",
|
|
56
57
|
"@types/lodash": "4.14.165",
|
|
57
58
|
"@types/uuid": "8.3.4",
|
|
58
59
|
"@types/fs-extra": "9.0.7",
|
|
59
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0.
|
|
60
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.80"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
63
|
"chai": "5.2.1",
|
|
File without changes
|