Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Secrets don't seem to exist with wrangler dev? #1172

Closed
mwisner opened this issue Jun 2, 2022 · 3 comments · Fixed by #1192 or #1193
Closed

🐛 BUG: Secrets don't seem to exist with wrangler dev? #1172

mwisner opened this issue Jun 2, 2022 · 3 comments · Fixed by #1192 or #1193
Assignees
Labels
bug Something that isn't working

Comments

@mwisner
Copy link

mwisner commented Jun 2, 2022

What version of Wrangler are you using?

2.0.7

What operating system are you using?

Mac

Describe the Bug

Honestly, I'm not sure if this is a bug or a user error... Maybe I'm doing something wrong here, but for the life of me I cannot figure out how to correctly handle secrets. I'm wondering if maybe there is a bug?

When I run: wrangler secret list -e staging I see the secrets in question listed.

Dev command: wrangler dev -e staging

I have a test secret named MATT

The index file looks like this:

import type { Env } from './types';

const worker = {
  /**
   *
   * @param request
   * @param env
   * @param ctx
   */
  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
    console.log(env);
    console.log(env.MATT);
    return new Response("HELLO");
  },
};

export default worker;

When I run wrangler dev -e staging env.MATT is always undefined. Even though it is showing up w/ wrangler secret list -e staging

Does anyone have any recommendations on how to best manage secrets during local development?

@mwisner mwisner added the bug Something that isn't working label Jun 2, 2022
@petebacondarwin
Copy link
Contributor

I wonder if this is the same as #1003?
Are you using routes in your wrangler.toml?

@mwisner
Copy link
Author

mwisner commented Jun 3, 2022

Hi @petebacondarwin ,

It might be? I am using routes but I've tried the workaround described in #1003 and still can't see any secrets. I could totally be doing the workaround incorrectly though... Maybe I'll hold off until #1003 and try again.

threepointone added a commit that referenced this issue Jun 6, 2022
When generating a preview session on the edge with `wrangler dev`, for a zoned worker we were using a random id as the script ID. This would make the backend not associate the dev session with any resources that were otherwise assigned to the script (specifically for secrets, but other stuff as well) The fix is simply to use the worker name (when available) as the script ID.

Fixes #1003
Fixes #1172
threepointone added a commit that referenced this issue Jun 6, 2022
…#1192)

When generating a preview session on the edge with `wrangler dev`, for a zoned worker we were using a random id as the script ID. This would make the backend not associate the dev session with any resources that were otherwise assigned to the script (specifically for secrets, but other stuff as well) The fix is simply to use the worker name (when available) as the script ID.

Fixes #1003
Fixes #1172
Repository owner moved this from Untriaged to Done in workers-sdk Jun 6, 2022
@threepointone
Copy link
Contributor

This should be fixed in wrangler@beta, and we'll do a full release later this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
3 participants