Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.0.0 silently swallows errors in load event #4532

Open
bdon opened this issue Aug 10, 2024 · 3 comments · May be fixed by #4912
Open

v4.0.0 silently swallows errors in load event #4532

bdon opened this issue Aug 10, 2024 · 3 comments · May be fixed by #4912
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed

Comments

@bdon
Copy link
Contributor

bdon commented Aug 10, 2024

maplibre-gl-js version: 4.5.1

browser: safari

Steps to Trigger Behavior

  1. throw any error or reference an uninitialized variable in the on("load",...) event.
  2. No error is printed to the console.

Link to Demonstration

Paste this in on JSBin: https://jsbin.com/

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Display a map</title>
    <meta property="og:description" content="Initialize a map in an HTML element with MapLibre GL JS." />
    <meta charset='utf-8'>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/maplibre-gl.css' />
    <script src='https://unpkg.com/[email protected]/dist/maplibre-gl.js'></script>
    <style>
        body { margin: 0; padding: 0; }
        html, body, #map { height: 100%; }
    </style>
</head>
<body>
<div id="map"></div>
<script>
    const map = new maplibregl.Map({
        container: 'map', // container id
        style: 'https://demotiles.maplibre.org/style.json', // style URL
        center: [0, 0], // starting position [lng, lat]
        zoom: 1, // starting zoom
        maplibreLogo: true
    });
  
    map.on("load", () => {
      console.log(variable_does_not_exist);
    })
</script>
</body>
</html>

Expected Behavior

On the last version of 3.x, console.error is called with ReferenceError: Can't find variable: variable_does_not_exist

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Display a map</title>
    <meta property="og:description" content="Initialize a map in an HTML element with MapLibre GL JS." />
    <meta charset='utf-8'>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/maplibre-gl.css' />
    <script src='https://unpkg.com/[email protected]/dist/maplibre-gl.js'></script>
    <style>
        body { margin: 0; padding: 0; }
        html, body, #map { height: 100%; }
    </style>
</head>
<body>
<div id="map"></div>
<script>
    const map = new maplibregl.Map({
        container: 'map', // container id
        style: 'https://demotiles.maplibre.org/style.json', // style URL
        center: [0, 0], // starting position [lng, lat]
        zoom: 1, // starting zoom
        maplibreLogo: true
    });
  
    map.on("load", () => {
      console.log(variable_does_not_exist);
    })
</script>
</body>
</html>

Actual Behavior

Nothing is printed to the console.

@HarelM
Copy link
Collaborator

HarelM commented Aug 11, 2024

Can you check if the following PR solve this issue as well?

@HarelM HarelM added the need more info Further information is requested label Aug 11, 2024
@bdon
Copy link
Contributor Author

bdon commented Aug 11, 2024

Yes, that solves the issue.

@HarelM
Copy link
Collaborator

HarelM commented Aug 11, 2024

Hmm... interesting, probably related to the fact that we catch everything and not just the abort exception...
CC: @xabbu42

@HarelM HarelM added bug Something isn't working PR is more than welcomed Extra attention is needed and removed need more info Further information is requested labels Aug 11, 2024
@HarelM HarelM linked a pull request Oct 28, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants