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

Error while deploying app with Edge Functions #110

Closed
adamduncan opened this issue Apr 4, 2023 · 3 comments · Fixed by #111
Closed

Error while deploying app with Edge Functions #110

adamduncan opened this issue Apr 4, 2023 · 3 comments · Fixed by #111
Assignees

Comments

@adamduncan
Copy link

adamduncan commented Apr 4, 2023

Describe the bug
Trying to build and deploy out-of-the-box remix-template to Netlify. No modifications made to template after install. App builds and runs locally with netlify dev without an issue. When running netlify deploy --build, seeing an error regarding excluded_patterns

2. Edge Functions bundling                                    
────────────────────────────────────────────────────────────────

Packaging Edge Functions from .netlify/edge-functions directory:
 - server

  Bundling of edge function failed                              
────────────────────────────────────────────────────────────────

  Error message
  Validation of Edge Functions manifest failed
  FORMAT excluded_patterns needs to be an array of regex that starts with ^ followed by / and ends with $ without any additional slashes before and afterwards

    19 |     "server": {
    20 |       "excluded_patterns": [
  > 21 |         "/_assets/*"
       |         ^^^^^^^^^^^^ 👈🏽  format excluded_patterns needs to be an array of regex that starts with ^ followed by / and ends with $ without any additional slashes before and afterwards
    22 |       ],
    23 |       "cache": "manual",
    24 |       "generator": "internalFunc"

  Error location
  While bundling edge function

  Resolved config
  build:
    command: npm run build
    commandOrigin: config
    publish: /Users/adamduncan/Websites/_examples/netlify-remix-template/public
    publishOrigin: config

To Reproduce
Steps to reproduce the behavior:

  1. npx create-remix@latest --template netlify/remix-template
  2. Choose TypeScript
  3. Run npm install
  4. Choose Run your Remix site with: Netlify Edge Functions (beta)
  5. cd into install directory
  6. netlify dev (works fine locally, including use of edge functions if created in /netlify/edge-functions/ dir)
  7. npm run build (succeeds)
  8. netlify deploy --build — fails with above message ☝️

Expected behavior
Successful deployment to Netlify

Screenshots

Screenshot 2023-04-04 at 19 26 22

Desktop:

  • OS: macOS Ventura 13.3 (22E252)
  • Browser: N/A
  • Node Version: v18.14.2

Additional context
As suggested, I attempted to set excluded_patterns to:

  • RegEx: excluded_patterns: [/^\/_assets\/\*$/] — Same error (same regardless of whether string/regex wrapped in new RegExp() or not)
  • String: excluded_patterns: ["^/_assets/*$"] — Builds and deploys successfully (example) but app isn't rendering as expected / as it does locally via netlify dev. Note: Interestingly, if I create an edge function, that is behaving as expected (example), even though the app itself isn't rendering.
  • None: excluded_patterns: [] — As above
@nickytonline
Copy link
Contributor

Thanks for reporting this @adamduncan! This was working and was tested so not sure what's up. I'll speak to the team to see if anything changed recently.

@nickytonline
Copy link
Contributor

nickytonline commented Apr 4, 2023

@adamduncan, I figured out the issue. One, the error is because things did get updated on our end, so

// Import path interpreted by the Remix compiler
import * as build from "@remix-run/dev/server-build";
import { createRequestHandler } from "@netlify/remix-edge-adapter";

export default createRequestHandler({
  build,
  // process.env.NODE_ENV is provided by Remix at compile time
  mode: process.env.NODE_ENV,
});

export const config = {
  cache: "manual",
  path: "/*",
  // Let the CDN handle requests for static assets, i.e. /_assets/*
  //
  // Add other exclusions here, e.g. "/api/*" for custom Netlify functions or
  // custom Netlify Edge Functions
-  excluded_patterns: ["/_assets/*"],
+  excluded_patterns: ["^/_assets/*$"],
};

but also, you'll need to update the app/routes/index.tsx to app/routes/_index.tsx. It's part of the new Remix routing. I have a PR up for it, but I guess it's no longer behind their future flag. See #105.

I'll create a PR to update both these things. Thanks again for reporting this!

@adamduncan
Copy link
Author

@nickytonline Thanks for following up on this so swiftly! Appreciate the insights 👍

Yep, looks like with that change to excluded_patterns: ["^/_assets/*$"] and the _index.tsx file renaming, things are deploying and functioning as expected: https://netlify-remix-template-test.netlify.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants