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

Fix network issue #944

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Fix network issue #944

wants to merge 4 commits into from

Conversation

HarelM
Copy link
Collaborator

@HarelM HarelM commented Sep 29, 2024

Launch Checklist

In case of non 200 response the font and glyphs metadata would return the ajax error object instead of the default value.

Fixes #935

  • Crash - TypeError: i.map is not a function #935

  • Briefly describe the changes in this PR.

  • Link to related issues.

  • Include before/after visuals or gifs if this PR includes visual changes.

  • Write tests for all new functionality.

  • Add an entry to CHANGELOG.md under the ## main section.

@HarelM HarelM requested a review from nyurik September 29, 2024 13:14
Copy link
Contributor

@pathmapper pathmapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, confirmed this fixes the issue.

src/libs/metadata.ts Outdated Show resolved Hide resolved
src/libs/metadata.ts Outdated Show resolved Hide resolved
Copy link
Member

@nyurik nyurik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

one side question - can't we use a much more readable await syntax?

try {
  let response = await fetch(url, {
    mode: 'cors',
    credentials: "same-origin"
  });
  if (!response.ok) {
    throw new Error('Failed to load metadata for ' + url);
  }
  cb(await response.json())
}
catch (ex) {
  console.warn('Can not load metadata for ' + url + ', using default value ' + defaultValue);
  cb(defaultValue)
}

@HarelM
Copy link
Collaborator Author

HarelM commented Nov 19, 2024

We could, I didn't want to change the code a lot ,and only wanted to solve this issue. It can be done as part of a different PR...

@HarelM
Copy link
Collaborator Author

HarelM commented Nov 19, 2024

In general, this callback hell should be removed, much like we did for maplibre, but it's not a small change...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash - TypeError: i.map is not a function
3 participants