redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.15k stars 979 forks source link

[Bug?]: Context is empty #11576

Open razzeee opened 3 days ago

razzeee commented 3 days ago

What's not working?

Context is {} when using it similar to https://github.com/redwoodjs/redwood/blob/2b749313203ff4308e60c6cb546b69301646add6/packages/auth-providers/dbAuth/setup/src/templates/api/lib/auth.ts.template#L49

The interesting this is, that we're still on redwood 7 and it seemed to break for no reason. I was guessing a dependency update, but wasn't able to pinpoint it so far.

It also seems to be fine in dev, but breaks for us with docker/deploy (our own docker stuff, pre redwood docker)

How do we reproduce the bug?

I'm lost on this so far, mostly want to reach out and see, if anything comes to mind. Might task a colleague to condense a repro repo, if nothing else happens.

What's your environment? (If it applies)

System:
    OS: Linux 6.10 Fedora Linux 40 (Workstation Edition)
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 20.16.0 - /tmp/xfs-6b43daa9/node
    Yarn: 4.4.1 - /tmp/xfs-6b43daa9/yarn
  Databases:
    SQLite: 3.45.1 - /usr/bin/sqlite3
  npmPackages:
    @redwoodjs/auth-custom-setup: 7.7.4 => 7.7.4 
    @redwoodjs/cli-data-migrate: 7.7.4 => 7.7.4 
    @redwoodjs/cli-storybook: 7.7.4 => 7.7.4 
    @redwoodjs/cli-storybook-vite: 7.7.4 => 7.7.4 
    @redwoodjs/core: 7.7.4 => 7.7.4 
  redwood.toml:
    [web]
      title = "slashskills"
      port = 8910
      apiUrl = "/.redwood/functions" # you can customise graphql and dbauth urls individually too: see https://redwoodjs.com/docs/app-configuration-redwood-toml#api-paths
      sourceMap = true
      includeEnvironmentVariables = [
        "GITLAB_CLIENT_ID",
        "GITLAB_REDIRECT_URI",
        "GITLAB_AUTHORITY",
        "SITE_ID",
        "BASE_URL",
        "SENTRY_DSN",
        "ENVIRONMENT",
        "SENTRY_ENABLED",
        "CI_COMMIT_SHA",
      ] # any ENV vars that should be available to the web side, see https://redwoodjs.com/docs/environment-variables#web
    [api]
      port = 8911
      host = "localhost"
    [browser]
      open = true

Are you interested in working on this?

ahaywood commented 2 days ago

@razzeee Thanks for reporting! This looks so strange. I'm tagging @Josh-Walker-GM and @Tobbe to see if they have any ideas or have seen anything similar?

Tobbe commented 2 days ago

Nothing that comes to mind right now I'm afraid

cannikin commented 2 days ago

Any more details? That code snippet is within dbAuth itself, which you normally don’t have access to within an app. Where are you accessing context and seeing that it’s equal to {}?

razzeee commented 2 days ago

I figured out how to get it to work again, but I'm not 100% sure, which part the actual fix was

We have had a docker setup since before it was available with redwood

RUN yarn global add @redwoodjs/cli prisma @sentry/cli && \
  prisma generate [...]

If I pin it like this, it starts working again:

RUN yarn global add @redwoodjs/cli@7.7.1 prisma@5.18.0 @sentry/cli && \

The prisma pin might actually not be needed, it started to work, after pinning the cli (we can probably pin something newer)

arimendelow commented 2 days ago

@razzeee, can you provide a small repo with a reproduction of this issue? And I echo @cannikin's question — where are you attempting to access context?

The only time I've seen context be unexpectedly empty is when experiencing cookie issues, though without more information it's tough to know what the issue could be.

razzeee commented 7 hours ago

I'm not sure, that there is much to repro.

It seems like installing @redwoodjs/cli global in a major version different from what your targeting can cause this. Pretty specific and IMO expected.

Our problem is just, that we need it in the pipeline right now and can't sync the version from package.json to Dockerfile in an automatic way. I guess if data migrate works correctly now, we might not need that anymore, would need to find time to look into that.