mirror of
https://github.com/strapi/strapi.git
synced 2025-12-16 09:45:08 +00:00
error handling for timeout in transfer
This commit is contained in:
parent
961938ad1e
commit
33cbe053cc
@ -303,15 +303,22 @@ class RemoteStrapiDestinationProvider implements IDestinationProvider {
|
|||||||
const startAssetsTransferOnce = this.#startStepOnce('assets');
|
const startAssetsTransferOnce = this.#startStepOnce('assets');
|
||||||
|
|
||||||
const flush = async () => {
|
const flush = async () => {
|
||||||
await this.#streamStep('assets', batch);
|
const streamError = await this.#streamStep('assets', batch);
|
||||||
batch = [];
|
batch = [];
|
||||||
|
return streamError;
|
||||||
};
|
};
|
||||||
|
|
||||||
const safePush = async (chunk: client.TransferAssetFlow) => {
|
const safePush = async (
|
||||||
|
chunk: client.TransferAssetFlow,
|
||||||
|
callback: (error?: Error | null) => void
|
||||||
|
) => {
|
||||||
batch.push(chunk);
|
batch.push(chunk);
|
||||||
|
|
||||||
if (batchLength() >= batchSize) {
|
if (batchLength() >= batchSize) {
|
||||||
await flush();
|
const streamError = await flush();
|
||||||
|
if (streamError) {
|
||||||
|
return callback(streamError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -347,13 +354,20 @@ class RemoteStrapiDestinationProvider implements IDestinationProvider {
|
|||||||
const assetID = v4();
|
const assetID = v4();
|
||||||
const { filename, filepath, stats, stream } = asset;
|
const { filename, filepath, stats, stream } = asset;
|
||||||
|
|
||||||
await safePush({ action: 'start', assetID, data: { filename, filepath, stats } });
|
await safePush(
|
||||||
|
{
|
||||||
|
action: 'start',
|
||||||
|
assetID,
|
||||||
|
data: { filename, filepath, stats },
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
|
||||||
for await (const chunk of stream) {
|
for await (const chunk of stream) {
|
||||||
await safePush({ action: 'stream', assetID, data: chunk });
|
await safePush({ action: 'stream', assetID, data: chunk }, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
await safePush({ action: 'end', assetID });
|
await safePush({ action: 'end', assetID }, callback);
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -6828,6 +6828,13 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.36.1.tgz#d4c01fdbbe909d128d1bf11c7f8b5431654c5b95"
|
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.36.1.tgz#d4c01fdbbe909d128d1bf11c7f8b5431654c5b95"
|
||||||
integrity sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==
|
integrity sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==
|
||||||
|
|
||||||
|
"@vscode/sqlite3@5.0.8":
|
||||||
|
version "5.0.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@vscode/sqlite3/-/sqlite3-5.0.8.tgz#72b07061c5f90a9dd598a5506f598fcc817fab90"
|
||||||
|
integrity sha512-6wvQdMjpi1kwYI5mfzm98siEQb2mlBKX4xdNtJFj/uNqb6wqd3JOhk+5FL7geR0hduXE5lHjv+q69jtsEtUJDA==
|
||||||
|
dependencies:
|
||||||
|
node-addon-api "^4.2.0"
|
||||||
|
|
||||||
"@vscode/sqlite3@5.1.2":
|
"@vscode/sqlite3@5.1.2":
|
||||||
version "5.1.2"
|
version "5.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/@vscode/sqlite3/-/sqlite3-5.1.2.tgz#3b22f2bd8681a7193f2169b407ae364b7b2c2dec"
|
resolved "https://registry.yarnpkg.com/@vscode/sqlite3/-/sqlite3-5.1.2.tgz#3b22f2bd8681a7193f2169b407ae364b7b2c2dec"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user