Edge function not deploying in Netlify monorepo project despite working locally with `netlify dev`

Problem:

Edge function is not deployed, even though it works with netlify dev. Likely because local build files created by netlify deploy end up in the wrong directory of the monorepo.

Expected:

  1. Create monorepo with Expo app as one of the packages (packages/client).
  2. Add Netlify setup, including an edge function.
  3. Test setup with netlify dev.
  4. Deploy with Netlify, and observe the edge function working. ← This step fails.

Observations:

  1. netlify dev prints “Loaded edge function hello” and the edge function works.
  2. netlify deploy prints “Packaging Edge Functions …” as expected, but these are not actually deployed, as is evident when visiting the website or looking at “Deploy summary” in Netlify dashboard.
  3. In packages/client a new directory is created by netlify deploy command which seems incorrect. This directory is called packages and at path packages/client/packages/client/.netlify there is what looks like something that should’ve been written to packages/client/.netlify.
  4. Adding base = "packages/client" to netlify.toml does not solve the problem.

Reproduce:

Clone repository https://github.com/santotan/netlifytest and follow instructions in README.md.

  • Site name: https://netlifytest9846.netlify.app/

Local build log

$ netlify deploy --build --prod --filter=client
​
Netlify Build                                                 
────────────────────────────────────────────────────────────────
​
❯ Version
  @netlify/build 29.51.3
​
❯ Flags
  packagePath: packages/client
​
❯ Current directory
  /Users/st/code/netlifytest/packages/client
​
❯ Config file
  /Users/st/code/netlifytest/packages/client/netlify.toml
​
❯ Context
  production
​
build.command from netlify.toml                               
────────────────────────────────────────────────────────────────
​
$ expo export -p web --clear
env: load .env
env: export EXPO_USE_METRO_WORKSPACE_ROOT
Starting Metro Bundler
warning: Bundler cache is empty, rebuilding (this may take a minute)
Static rendering is enabled. Learn more: https://docs.expo.dev/router/reference/static-rendering/
Web Bundled 8280ms node_modules/expo-router/entry.js (762 modules)
λ Bundled 8521ms node_modules/expo-router/node/render.js (777 modules)

Exporting 6 static routes:
/ (index) (18.3 kB)
/explore (21.5 kB)
/_sitemap (20.3 kB)
/+not-found (17.5 kB)
/(tabs) (18.3 kB)
/(tabs)/explore (21.5 kB)

Exporting 1 bundle for web:
_expo/static/js/web/entry-c3e42f74fba1d58f1b993e0170f58e75.js (1.43 MB)

Exporting 13 files:
assets/__node_modules/@expo/vector-icons/build/vendor/react-native-vector-icons/Fonts/Ionicons.6148e7019854f3bde85b633cb88f3c25.ttf (443 kB)
assets/__node_modules/@react-navigation/elements/lib/module/assets/back-icon-mask.5223c8d9b0d08b82a5670fb5f71faf78.png (913 B)
assets/__node_modules/@react-navigation/elements/lib/module/assets/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png (207 B)
assets/__node_modules/expo-router/assets/error.563d5e3294b67811d0a1aede6f601e30.png (516 B)
assets/__node_modules/expo-router/assets/file.b6c297a501e289394b0bc5dc69c265e6.png (158 B)
assets/__node_modules/expo-router/assets/forward.9d9c5644f55c2f6e4b7f247c378b2fe9.png (250 B)
assets/__node_modules/expo-router/assets/pkg.5974eb3e1c5314e8d5a822702d7d0740.png (429 B)
assets/assets/fonts/SpaceMono-Regular.49a79d66bdea2debf1832bf4d7aca127.ttf (93.3 kB)
assets/assets/images/partial-react-logo.8f14e478886737f3323a2ac79c833749.png (5.08 kB)
assets/assets/images/react-logo.d883906de993aa65bf0ef0d1bc2ff6ad.png (6.34 kB)
assets/assets/images/react-logo.d883906de993aa65bf0ef0d1bc2ff6ad@2x.png (14.2 kB)
assets/assets/images/react-logo.d883906de993aa65bf0ef0d1bc2ff6ad@3x.png (21.3 kB)
favicon.ico (14.5 kB)

App exported to: dist
​
(build.command completed in 9.9s)
​
Edge Functions bundling                                       
────────────────────────────────────────────────────────────────
​
Packaging Edge Functions from netlify/edge-functions directory:
 - hello
​
(Edge Functions bundling completed in 438ms)
Deploy path:        /Users/st/code/netlifytest/packages/client/dist
Configuration path: /Users/st/code/netlifytest/packages/client/netlify.toml
Deploying to main site URL...
⠋ Uploading blobs to deploy store...
​
Netlify Build                                                 
────────────────────────────────────────────────────────────────
​
❯ Version
  @netlify/build 29.51.3
​
❯ Flags
  build: true
  deployId: 669e60c5c378a24b954bdb52
  filter: client
  open: false
  packagePath: packages/client
  prod: true
  prodIfUnlocked: false
  skipFunctionsCache: false
​
❯ Current directory
  /Users/st/code/netlifytest
​
❯ Config file
  /Users/st/code/netlifytest/packages/client/netlify.toml
​
❯ Context
✔ Finished uploading blobs to deploy store
✔ No cached functions were found
✔ Finished hashing 
✔ CDN requesting 0 files
✔ Finished uploading 0 assets
✔ Deploy is live!
​
Netlify Build Complete                                        
────────────────────────────────────────────────────────────────
​
(Netlify Build completed in 15.4s)

Would anyone be able to advise either to how to solve the issue or how to seek out help better?

I’ve created a minimal working example using Expo template project, so this should be easily reproducible.

I’ve asked the devs to take a look.

1 Like