Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(map): pin mapbox-gl to 3.32.0 so vector tiles load beside maplibre-gl

Maurice293ec89db4f5
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 584aa403a..2cc3a828f 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -35,6 +35,13 @@ updates:
# tooling supports it.
- dependency-name: typescript
update-types: [version-update:semver-major]
+ # mapbox-gl 3.33 and later read the worker registry key before handling
+ # Set and Error, and maplibre-gl, bundled beside it, stamps that key on
+ # both built-ins: every vector tile then fails with "reading 'omit'".
+ # glWorkerRegistry.test.ts fails on a version with that order; it moves
+ # by hand once mapbox-gl checks the built-ins first again.
+ - dependency-name: mapbox-gl
+ versions: ['>=3.33.0']
# plugin-sdk is standalone with a lockfile of its own and ships to npm.
- package-ecosystem: npm
diff --git a/client/package.json b/client/package.json
index 885613f3c..ff656e548 100644
--- a/client/package.json
+++ b/client/package.json
@@ -112,7 +112,7 @@
"iso-3166-2": "^1.0.0",
"leaflet": "^1.9.4",
"lucide-react": "^0.577.0",
- "mapbox-gl": "^3.35.2",
+ "mapbox-gl": "3.32.0",
"maplibre-gl": "6.19.0",
"modern-screenshot": "4.7.0",
"plyr": "^3.8.5",
diff --git a/client/src/components/Map/glWorkerRegistry.test.ts b/client/src/components/Map/glWorkerRegistry.test.ts
new file mode 100644
index 000000000..dd3e1506f
--- /dev/null
+++ b/client/src/components/Map/glWorkerRegistry.test.ts
@@ -0,0 +1,45 @@
+import { readFileSync } from 'node:fs';
+import { createRequire } from 'node:module';
+import { dirname, join } from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+// mapbox-gl and maplibre-gl ship in the same bundle, and both pass messages to
+// their workers through a class registry that stamps `_classRegistryKey` on
+// constructors. maplibre stamps the built-ins Set and Error globally. mapbox-gl
+// 3.33 and later read that key before their own Set and Error handling, find no
+// entry for "Set" in their registry and throw "Cannot read properties of
+// undefined (reading 'omit')" for every vector tile, so the Mapbox basemap stays
+// blank while raster layers still load. These read the shipped files because the
+// clash only exists between the two real libraries.
+const requireFromClient = createRequire(import.meta.url);
+
+function distFile(pkg: string, file: string): string {
+ const root = dirname(requireFromClient.resolve(`${pkg}/package.json`));
+ return readFileSync(join(root, 'dist', file), 'utf8');
+}
+
+function functionBody(source: string, signature: string): string {
+ const start = source.indexOf(signature);
+ expect(start, `${signature} not found`).toBeGreaterThan(-1);
+ return source.slice(start, source.indexOf('\n}\n', start));
+}
+
+describe('GL worker class registry', () => {
+ it('FE-COMP-GLWORKERREGISTRY-001: maplibre-gl stamps the global Set and Error', () => {
+ const maplibre = distFile('maplibre-gl', 'maplibre-gl-dev.mjs');
+ expect(maplibre).toMatch(/register\("Set", Set\)/);
+ expect(maplibre).toMatch(/register\("Error", Error\)/);
+ });
+
+ it('FE-COMP-GLWORKERREGISTRY-002: mapbox-gl handles Set and Error before it reads the registry key', () => {
+ const serialize = functionBody(
+ distFile('mapbox-gl', 'mapbox-gl-dev.js'),
+ 'function serialize(input, transferables)'
+ );
+ const registryRead = serialize.indexOf('._classRegistryKey');
+ expect(registryRead).toBeGreaterThan(-1);
+ expect(serialize.indexOf('instanceof Set')).toBeGreaterThan(-1);
+ expect(serialize.indexOf('instanceof Set')).toBeLessThan(registryRead);
+ expect(serialize.indexOf('instanceof Error')).toBeLessThan(registryRead);
+ });
+});
diff --git a/package-lock.json b/package-lock.json
index 49316bfd4..6b41e7906 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -91,7 +91,7 @@
"iso-3166-2": "^1.0.0",
"leaflet": "^1.9.4",
"lucide-react": "^0.577.0",
- "mapbox-gl": "^3.35.2",
+ "mapbox-gl": "3.32.0",
"maplibre-gl": "6.19.0",
"modern-screenshot": "4.7.0",
"plyr": "^3.8.5",
@@ -17859,9 +17859,9 @@
}
},
"node_modules/mapbox-gl": {
- "version": "3.35.2",
- "resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-3.35.2.tgz",
- "integrity": "sha512-xM+0319FNTS2iOxl0Jelousi31L+ckzOxaXKkIlelanSe2jMlRRNVv3ESezPj6eUGlTDrfaxefk5QM6wQ3ICgg==",
+ "version": "3.32.0",
+ "resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-3.32.0.tgz",
+ "integrity": "sha512-+P4qrlyejQYLyz1Bfzoe+d5Ff5vAghH54RNHm1q2VeAZqkSjQ5e1XlovQoSHlf4xqpRJtJG58kn8nkLwPMQung==",
"license": "SEE LICENSE IN LICENSE.txt",
"workspaces": [
"src/style-spec",