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

getLoadContext does not execute when passed to createRequestHandler #94

Closed
juanpprieto opened this issue May 27, 2023 · 4 comments
Closed
Labels
Ecosystem: Frameworks type: bug code to address defects in shipped code

Comments

@juanpprieto
Copy link

juanpprieto commented May 27, 2023

Hi @nickytonline hope you are well 🙏🏼

I been trying to add a context property in the edge template without any luck.

// server.js

import { createRequestHandler } from "@remix-run/netlify";
import * as build from "@remix-run/dev/server-build";

export const handler = createRequestHandler({
  build,
  mode: process.env.NODE_ENV,
  getLoadContext: (_, context) => {
    console.log('🤷 not being called...') 
    return { ...context, foo: 'bar' }
  }
});

I checked a loader context's and it is missing the additional foo property added above.

I then tried debugging it via the /packages/demo-edge-site but the demo instance seems to be broken:

/remix-compute/packages/edge-demo-site main* ❯ npm run dev                           12:17:07

> [email protected] dev
> remix dev

Error: remix dev is not supported for custom servers.
    at Object.serve (/Users/jbaz/code-work/2023/remix-compute/node_modules/@remix-run/dev/dist/devServer/serve.js:41:11)
    at Object.dev (/Users/jbaz/code-work/2023/remix-compute/node_modules/@remix-run/dev/dist/cli/commands.js:215:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async dev (/Users/jbaz/code-work/2023/remix-compute/node_modules/@remix-run/dev/dist/cli/run.js:194:3)
    at async Object.run (/Users/jbaz/code-work/2023/remix-compute/node_modules/@remix-run/dev/dist/cli/run.js:477:7)
npm ERR! Lifecycle script `dev` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: [email protected]
npm ERR!   at location: /Users/jbaz/code-work/2023/remix-compute/packages/edge-demo-site
@nickytonline
Copy link
Contributor

nickytonline commented May 29, 2023

@juanpprieto, hmmm, that could be a bug with context.

You can update the dev command to remix watch and then run netlify dev from the root of the project (not packages/edge-demo-site). Ensure the Netlify CLI is installed/up to date. See https://docs.netlify.com/cli/get-started/

/netlify.toml

[build]
command = "npm run build:edge-demo"
publish = "packages/edge-demo-site/public"
+
+ [dev]
+ command = "npm run dev -w packages/edge-demo-site"

I'll update the dev command and netlify.toml for the demo site. As the remix dev command says, the dev server doesn't work for custom servers, i.e. not a node.js environment.

@nickytonline
Copy link
Contributor

If you make changes while debugging, you'll need to do a browser refresh if you make UI changes. For Edge function changes, the next request will pick up the latest changes.

@jtaccinelli
Copy link

Just flagging this again as I'm also unable to do this, even with the steps described here. The createRequestHandler function just straight up isn't being called. Has there been any solution found?

@serhalp serhalp added the type: bug code to address defects in shipped code label May 24, 2024
@serhalp
Copy link
Contributor

serhalp commented Sep 17, 2024

@juanpprieto @jtaccinelli We're sorry you didn't get a prompt response here. I hope you were able to resolve your issue. Since this issue is quite stale, I'm going to close it, but please feel free to open a new issue with repro steps if you're still having issues, or (even better) seek help at https://answers.netlify.com/. Thanks.

@serhalp serhalp closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ecosystem: Frameworks type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

4 participants