Skip to content

await SecretsStore.get() does not work from global context #13445

@touhidurrr

Description

@touhidurrr

What versions & operating system are you using?

  System:
    OS: Windows 11 10.0.26200
    CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics 

    Memory: 7.00 GB / 19.33 GB
  Binaries:
    Node: 24.14.1 - C:\Users\touhi\scoop\apps\nodejs-lts\current\node.EXE
    Yarn: 1.22.22 - C:\Users\touhi\.bun\bin\yarn.EXE     
    npm: 11.6.2 - C:\Users\touhi\scoop\apps\nodejs-lts\current\bin\npm.CMD
    pnpm: 10.30.3 - C:\Users\touhi\.bun\bin\pnpm.EXE     
    bun: 1.3.12 - C:\Users\touhi\.bun\bin\bun.EXE        
  npmPackages:
    @cloudflare/workers-types: ^4.20260409.1 => 4.20260409.1
    wrangler: ^4.81.1 => 4.81.1

Please provide a link to a minimal reproduction

https://github.com/touhidurrr/uncivgames-dbot/blob/4114b95fd16bc3f3d43dc914fe02bb7314cee613/src/modules/prisma.ts

Describe the Bug

await SecretsStore.get() does not work from global context

Please provide any relevant error logs

X [ERROR] A request to the Cloudflare API (/accounts/2abd5f3a5cdcf01e98291c0a7a1f47e4/workers/scripts/dbot/versions) failed.

  Uncaught Error: Disallowed operation called within     
  global scope. Asynchronous I/O (ex: fetch() or
  connect()), setting a timeout, and generating random   
  values are not allowed within global scope. To fix this
  error, perform this operation within a handler.        
  https://developers.cloudflare.com/workers/runtime-apis/handlers/
    at null.<anonymous>
  (file:///C:/Users/touhi/projects/uncivgames-dbot/src/modules/prisma.ts:6:26)
   [code: 10021]
  To learn more about this error, visit:
  https://developers.cloudflare.com/workers/observability/errors/#validation-errors-10021


  If you think this is a bug, please open an issue at:   
  https://github.com/cloudflare/workers-sdk/issues/new/choose

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions