Skip to content

🐛 BUG: Malformed _routes.json does not throw error but fails silently #5308

@shripadk

Description

@shripadk

Which Cloudflare product(s) does this pertain to?

Pages, Workers Runtime, Wrangler core, Miniflare

What version(s) of the tool(s) are you using?

3.35.0

What version of Node are you using?

v21.7.0

What operating system and version are you using?

Linux 6.7.9-arch1-1

Describe the Bug

Observed behavior

Deploys to Pages successfully without throwing any errors but does not upload _routes.json file

Expected behavior

Must fail deployment and complain about _routes.json being malformed.

Steps to reproduce

Please provide the following:

  • A minimal working subset of your worker code
/mnt/work/cf-test> ls                                                                       03/20/2024 11:47:58 AM
╭───┬──────────────┬──────┬─────────┬────────────────╮
│ # │     name     │ type │  size   │    modified    │
├───┼──────────────┼──────┼─────────┼────────────────┤
│ 0 │ _headers     │ file │   129 B │ 24 minutes ago │
│ 1 │ _routes.json │ file │    71 B │ 27 minutes ago │
│ 2 │ _worker.js   │ file │   101 B │ 24 minutes ago │
│ 3 │ assets       │ dir  │ 4.0 KiB │ 27 minutes ago │
╰───┴──────────────┴──────┴─────────┴────────────────╯

_worker.js:

export default {
  async fetch(request, env, ctx) {
    return new Response('Hello World!');
  },
};

_routes.json: (note the trailing comma after "/assets/*", ← quite common issue)

{
   "version": 1,
   "include": ["/*"],
   "exclude": [
      "/assets/*",
    ]
}

_headers:

/favicon.ico
  Cache-Control: public, max-age=3600, s-maxage=3600
/assets/*
  Cache-Control: public, max-age=31536000, immutable

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

Should throw an error in this situation!

Metadata

Metadata

Labels

pagesRelating to Pages

Type

No fields configured for Bug.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions