From dc8e14fff6c30639f2529c78970e267e4810960f Mon Sep 17 00:00:00 2001 From: Alessandro Kreslin Date: Thu, 3 Dec 2026 08:10:46 -0500 Subject: [PATCH] fix: upgrade maplibre-gl to 5.24.1 to stop WebGL context-restore crash MapLibre 5.16.0 crashes with "Cannot read properties of null (reading 'imageManager')" when the WebGL context is lost while a style is still loading: the lost-context snapshot has no style, so the restore handler skips setStyle() and then dereferences the null style. MapLibre 5.23.0 added a null guard for this. Sentry: MOBILITY-DATABASE-WEB-APP-43. The new MapLibre no longer pulls in the global GeoJSON type namespace, so Map.tsx and MapGeoJSON.tsx now import their types from 'geojson' and @types/geojson is declared as a dev dependency. Co-Authored-By: Claude Opus 5.5 --- package.json | 3 +- src/app/components/Map.tsx | 3 +- src/app/components/MapGeoJSON.tsx | 3 +- yarn.lock | 131 +++++++++++++----------------- 4 files changed, 62 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index c2e4d6f0..4368442f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "firebase-admin": "^13.0.2", "formik": "^2.4.5", "loadashes6": "^1.0.0", - "maplibre-gl": "^5.7.0", + "maplibre-gl": "^5.24.1", "material-react-table": "^2.13.0", "next": "16.1.1", "next-intl": "^4.7.0", @@ -90,6 +90,7 @@ "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^13.5.0", "@types/cypress": "^1.1.3", + "@types/geojson": "^7946.0.16", "@types/jest": "^30.0.0", "@types/material-ui": "^0.21.12", "@types/node": "^24.0.0", diff --git a/src/app/components/Map.tsx b/src/app/components/Map.tsx index 2d341e88..1931dc63 100644 --- a/src/app/components/Map.tsx +++ b/src/app/components/Map.tsx @@ -8,6 +8,7 @@ import MapGL, { MapProvider, } from 'react-map-gl/maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; +import type { Feature, Polygon } from 'geojson'; import { type LngLatTuple } from '../types'; import { Box } from '@mui/material'; import { getBoundsFromCoordinates } from './GtfsVisualizationMap.functions'; @@ -38,7 +39,7 @@ export const Map = ( coordinates.push(coordinates[0]); } - const polygonGeoJSON: GeoJSON.Feature = { + const polygonGeoJSON: Feature = { type: 'Feature', geometry: { type: 'Polygon', diff --git a/src/app/components/MapGeoJSON.tsx b/src/app/components/MapGeoJSON.tsx index a4bb03a7..5b3e3cdc 100644 --- a/src/app/components/MapGeoJSON.tsx +++ b/src/app/components/MapGeoJSON.tsx @@ -8,6 +8,7 @@ import MapGL, { Popup, } from 'react-map-gl/maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; +import type { FeatureCollection } from 'geojson'; import { type LngLatTuple } from '../types'; import { useTranslations } from 'next-intl'; import { PopupTable } from './PopupTable'; @@ -111,7 +112,7 @@ export const MapGeoJSON = (