diff --git a/doc/api/url.md b/doc/api/url.md index 3fa589397f77d6..36355493d3888a 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -659,7 +659,8 @@ added: v16.7.0 * `id` {string} A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`. -Removes the stored {Blob} identified by the given ID. +Removes the stored {Blob} identified by the given ID. Attempting to revoke a +ID that isn’t registered will silently fail. ### Class: `URLSearchParams` diff --git a/src/node_blob.cc b/src/node_blob.cc index 0d23158256cd9b..e1bf3be2b07b9e 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -444,7 +444,9 @@ void BlobBindingData::store_data_object( } void BlobBindingData::revoke_data_object(const std::string& uuid) { - CHECK_NE(data_objects_.find(uuid), data_objects_.end()); + if (data_objects_.find(uuid) == data_objects_.end()) { + return; + } data_objects_.erase(uuid); CHECK_EQ(data_objects_.find(uuid), data_objects_.end()); } diff --git a/test/parallel/test-blob-createobjecturl.js b/test/parallel/test-blob-createobjecturl.js index a8fd377dd3ef70..70c64b138db1ac 100644 --- a/test/parallel/test-blob-createobjecturl.js +++ b/test/parallel/test-blob-createobjecturl.js @@ -29,6 +29,10 @@ const assert = require('assert'); Buffer.from(await otherBlob.arrayBuffer()).toString(), 'hello'); URL.revokeObjectURL(id); + + // should do nothing + URL.revokeObjectURL(id); + assert.strictEqual(resolveObjectURL(id), undefined); // Leaving a Blob registered should not cause an assert