Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/storage/utils/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export async function notifyCollab(api, url, env) {
// method: 'POST',
headers,
});
resp.body.cancel();
resp.body?.cancel();
}
16 changes: 16 additions & 0 deletions test/storage/utils/object.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ describe('Storage Object Utils tests', () => {
assert.strictEqual(called.length, 0, 'should not have invalidated anything');
});

it('does not throw when collab response has null body', async () => {
// Regression test: notifyCollab calls resp.body.cancel() unconditionally. When the collab
// service returns a response with no body (null), this throws TypeError: Cannot read
// properties of null (reading 'cancel'). In copyFile this fires in a finally block,
// which cancels the return value and causes the move to fail with partial_failure 500 —
// leaving the file duplicated at both source and destination.
const env = {
dacollab: {
fetch: async () => ({ body: null }),
},
};
await assert.doesNotReject(
notifyCollab('syncadmin', 'https://admin.da.live/source/a/b/c.html', env),
);
});

it('Should invalidate (with shared secret', async () => {
const called = [];
const env = {
Expand Down
Loading