Skip to content

Commit

Permalink
colossus: v3.8.2 backport fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaamani committed Jan 4, 2024
1 parent 8897fc5 commit 8cf54d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions storage-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.8.2

- Hotfix - backporting fixes

### 3.8.1

- Hotfix: Fix call stack size exceeded when handling large number of initial object to sync.
Expand Down
2 changes: 1 addition & 1 deletion storage-node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "storage-node",
"description": "Joystream storage subsystem.",
"version": "3.8.1",
"version": "3.8.2",
"author": "Joystream contributors",
"bin": {
"storage-node": "./bin/run"
Expand Down
7 changes: 4 additions & 3 deletions storage-node/src/services/queryNode/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,18 @@ export class QueryNodeApi {
*/
public async getDataObjectDetails(bagIds: string[]): Promise<Array<DataObjectDetailsFragment>> {
const allBagIds = [...bagIds] // Copy to avoid modifying the original array
const fullResult: DataObjectDetailsFragment[] = []
let fullResult: DataObjectDetailsFragment[] = []
while (allBagIds.length) {
const bagIdsBatch = allBagIds.splice(0, 1000)
const input: StorageBagWhereInput = { id_in: bagIdsBatch }
fullResult.push(
fullResult = [
...fullResult,
...(await this.multipleEntitiesWithPagination<
DataObjectDetailsFragment,
GetDataObjectConnectionQuery,
GetDataObjectConnectionQueryVariables
>(GetDataObjectConnection, { limit: MAX_RESULTS_PER_QUERY, bagIds: input }, 'storageDataObjectsConnection'))
)
]
}

return fullResult
Expand Down
11 changes: 11 additions & 0 deletions storage-node/src/services/sync/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ export class DownloadFileTask implements SyncTask {
if (!res.ok) {
logger.error(`Sync - unexpected status code(${res.statusCode}) for ${res?.request?.url}`)
}

// Handle 'error' event on Response too, because it will be emitted if request was
// prematurely aborted/closed due to timeout and the response still was not completed
// See: https://github.com/nodejs/node/blob/cd171576b2d1376dae3eb371b6da5ccf04dc4a85/lib/_http_client.js#L439-L441
res.on('error', (err: Error) => {
logger.error(`Sync - fetching data error for ${this.url}: ${err}`, { err })
})
})

request.on('error', (err) => {
logger.error(`Sync - fetching data error for ${this.url}: ${err}`, { err })
})
await streamPipeline(request, fileStream)
await this.verifyDownloadedFile(tempFilePath)
Expand Down

0 comments on commit 8cf54d5

Please sign in to comment.