Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

UnhandledPromiseRejection when deleting an object that doesn't exist in a bucket #867

@ragrag

Description

@ragrag

Receiving UnhandledPromiseRejection when deleting an object that doesn't exist in a bucket

  async deleteByName(imageName) {
    try {
      await this.storage
        .bucket('this-or-that')
        .file(imageName)
        .delete();
    } catch (err) {
      throw err;
    }
  }

Calling this method with an object that doesn't exist produces

(node:17744) UnhandledPromiseRejectionWarning: Error: No such object: this-or-that/user5d8f564fc428814550deee2c
    at new ApiError (G:\Projects\nodejs\this-or-that\node_modules\@google-cloud\common\build\src\util.js:60:15)
    at Util.parseHttpRespBody (G:\Projects\nodejs\this-or-that\node_modules\@google-cloud\common\build\src\util.js:195:38)
    at Util.handleResp (G:\Projects\nodejs\this-or-that\node_modules\@google-cloud\common\build\src\util.js:136:117)
    at retryRequest (G:\Projects\nodejs\this-or-that\node_modules\@google-cloud\common\build\src\util.js:431:22)
    at onResponse (G:\Projects\nodejs\this-or-that\node_modules\retry-request\index.js:206:7)
    at G:\Projects\nodejs\this-or-that\node_modules\teeny-request\build\src\index.js:256:13
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:17744) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:17744) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.

Environment details

  • OS: Windows 10 64bit
  • Node.js version: 10.16.0
  • npm version: 6.9.0
  • @google-cloud/storage version: 3.3.0

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/nodejs-storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions