Suddenly can't run my project in development - TypeError: Unexpected MODIFIER at 32, expected END

I created a report over in GitHub as well. I’m not sure if this is bug or something else. Here is what I wrote over in GitHub with most of the error trace documented.

Which Cloudflare product(s) does this pertain to?

Pages

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

3.22.4 [Wrangler] 8.14.1 [pnpm] 1.8.7 [solidjs] 5.0.10 [vite]

What version of Node are you using?

18.16.0

What operating system are you using?

Mac

Describe the Bug

I upgrade pnpm. I believe this was the only package change I made. I ran my dev command for my Pages project which had been running fine. Here is the commend:

pnpm wrangler pages dev --compatibility-date=2024-01-14 --kv=USER_SESSIONS -- pnpm run dev

I recently updated the compatibility date.

The project was running fine yesterday during work on it. Today I got this error and I am not sure how to understand it.

In the browser, I get this as the location of the error and the file:

/fww-live-app-solid/.wrangler/tmp/bundle-da8vsa/middleware-loader.entry.ts

	env,
	ctx
) {
	if (worker.fetch === undefined)
		throw new Error("Handler does not export a fetch() function.");
	return worker.fetch(request, env, ctx); // This line is highlighted as the error
};

function getMaskedEnv(rawEnv: unknown) {
	let env = rawEnv as Record<string, unknown>;
	if (worker.envWrappers && worker.envWrappers.length > 0) {
   

I also get a list of files that have issues with errors:

/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/path-to-regexp/src/index.ts

Missing stack frames

/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/path-to-regexp/src/index.ts

Missing stack frames


A few other files like this that seem related to pnpm…

But then I have this that is Worker related.

/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/pages-template-worker.ts:70:24

Here is the error in the browser window.

if (route.method && route.method !== request.method) {
			continue;
		}

		// replaces with "\\DISCOURSE_PLACEHOLDER_7", this prepends a backslash to the matched string, e.g. "[" becomes "\["
		const routeMatcher = match(route.routePath.replace(escapeRegex, "\\DISCOURSE_PLACEHOLDER_7"), { // This line is where the error is highlighted
			end: false,
		});
		const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\DISCOURSE_PLACEHOLDER_7"), {
			end: false,
		});

Another Worker related file.

/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/pages-template-worker.ts:135:35

					url = new URL(input, request.url).toString();
				}
				request = new Request(url, init);
			}

			const result = handlerIterator.next(); // This line is where the error is highlighted
			// Note we can't use `!result.done` because this doesn't narrow to the correct type
			if (result.done === false) {
				const { handler, params, path } = result.value;
				const context = {
					request: new Request(request.clone()),

One more example…

/fww-live-app-solid/.wrangler/tmp/bundle-da8vsa/middleware-loader.entry.ts:46:16

The error in the browser.

	env,
	ctx
) {
	if (worker.fetch === undefined)
		throw new Error("Handler does not export a fetch() function.");
	return worker.fetch(request, env, ctx); // This is where the error is highlighted
};

function getMaskedEnv(rawEnv: unknown) {
	let env = rawEnv as Record<string, unknown>;
	if (worker.envWrappers && worker.envWrappers.length > 0) {

I don’t fully understand what happened since again the only action I took was updating pnpm…

I did update Wrangler as well when this error happened. But I was only a minor version off. I was on 3.22.1 of Wrangler.

Please help as my project is at a standstill and I’m slightly freaking out. Haha.

Thank you so much!

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

In the console of my browswer I get this error log:

[wrangler:err] TypeError: Unexpected MODIFIER at 32, expected END
    at mustConsume (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/path-to-regexp/src/index.ts:157:11)
    at parse (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/path-to-regexp/src/index.ts:227:5)
    at stringToRegexp (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/path-to-regexp/src/index.ts:493:25)
    at pathToRegexp (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/path-to-regexp/src/index.ts:620:10)
    at match (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/path-to-regexp/src/index.ts:379:14)
    at executeRequest (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/pages-template-worker.ts:70:24)
    at [object Object]
    at next (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/pages-template-worker.ts:135:35)
    at Object.fetch (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/pages-template-worker.ts:180:17)
    at __facade_modules_fetch__ (file:///Users/devdan/Documents/NeverBackDown/fww/fww-live-app-solid/.wrangler/tmp/bundle-da8vsa/middleware-loader.entry.ts:46:16)