Skip to content

fix: throw when LatLng is non-finite#2182

Merged
JaffaKetchup merged 7 commits into
fleaflet:masterfrom
monsieurtanuki:fix/2178
Mar 1, 2026
Merged

fix: throw when LatLng is non-finite#2182
JaffaKetchup merged 7 commits into
fleaflet:masterfrom
monsieurtanuki:fix/2178

Conversation

@monsieurtanuki

Copy link
Copy Markdown
Contributor

Now we throw an Exception when a LatLng is NaN - at projection time.
Doesn't look particularly good, but at least we avoid a memory leak, and anyway, who put the NaN in the first place?
Image

The code isn't bullet proof as developers may extend Crs differently, but in most cases that should work.
And it's good enough.

@JaffaKetchup

Copy link
Copy Markdown
Member

Sorry for not responding sooner. Would it make sense to check if either number is not finite? Then we'll protect against infinities as well.

@monsieurtanuki

Copy link
Copy Markdown
Contributor Author

@JaffaKetchup Had to fix unrelated code too, because of parameter_assignments lint.

But the build fails because of too strict parameters.
We cannot reach a pub.dev score of 160/160, because we use Logger that only reaches 150 (doesn't officially support wasm).

@monsieurtanuki

Copy link
Copy Markdown
Contributor Author

@JaffaKetchup I've just "fixed" the score part: we now expect the top score - 10.

@JaffaKetchup

Copy link
Copy Markdown
Member

Annoyingly, we do support WASM. I'll write a PR to remove logger and replace with logging.

@JaffaKetchup JaffaKetchup changed the title fix: throwing when LatLng is NaN fix: prevent throwing when LatLng is non-finite & fix analysis warnings Feb 28, 2026
@JaffaKetchup

Copy link
Copy Markdown
Member

#2185 is that PR. I've removed your change to the workflow. Thanks for all the other fixes, happy with those as well! We can merge this once #2185 is merged first.

@JaffaKetchup JaffaKetchup self-requested a review February 28, 2026 15:31

@JaffaKetchup JaffaKetchup left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks again :)

@JaffaKetchup JaffaKetchup enabled auto-merge (squash) February 28, 2026 15:32
@monsieurtanuki

Copy link
Copy Markdown
Contributor Author

#2185 is that PR. I've removed your change to the workflow. Thanks for all the other fixes, happy with those as well! We can merge this once #2185 is merged first.

Thank you @JaffaKetchup! For the record in the current PR I also fixed issues for score 160, beyond using logger. Feel free to find inspiration here.

@JaffaKetchup JaffaKetchup disabled auto-merge March 1, 2026 13:08
@JaffaKetchup JaffaKetchup changed the title fix: prevent throwing when LatLng is non-finite & fix analysis warnings fix: prevent throwing when LatLng is non-finite Mar 1, 2026
@JaffaKetchup

Copy link
Copy Markdown
Member

Thanks, yeah all fixed there. I reverted those unrelated changes here as well. Unfortunately we still don't get 160 points due to dart-lang/pana#1571 -> dart-lang/pub-dev#6785 (comment).

Should be good to merge now, thanks again!

@JaffaKetchup JaffaKetchup enabled auto-merge (squash) March 1, 2026 13:33
@JaffaKetchup JaffaKetchup merged commit fdc089a into fleaflet:master Mar 1, 2026
11 checks passed
@monsieurtanuki

Copy link
Copy Markdown
Contributor Author

@JaffaKetchup As far as I can see, we're only using static consts, and simple methods HttpDate.format(DateTIme) and HttpDate.parse(String).
We could copy/paste the needed code. Nothing to be very proud of, but it's open source and it's somehow blocking us.

@JaffaKetchup

JaffaKetchup commented Mar 1, 2026

Copy link
Copy Markdown
Member

Yeah, it's an option, but not ideal. I'll see where dart-lang/http#1887 goes first - probably nowhere fast though! Might have to copy it anyway...

@JaffaKetchup

JaffaKetchup commented Jun 30, 2026

Copy link
Copy Markdown
Member

This has been reverted in #2218 as it caused un-forseen issues. Sorry, this was my fault, should've reviewed better!

#2213 introduced a specific check/fix for this case. #2199 was caused by other internal bugs, such as NaNs being produced unexpectedly. A new issue will be opened to investigate this.

@JaffaKetchup

Copy link
Copy Markdown
Member

Sorry again! See #2219 for a full explanation and timeline.

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.

LatLng with double.nan in Marker/MarkerLayer triggers memory leak

2 participants