Skip to content

fix: prevent throwing when LatLng is non-finite#2182

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

fix: prevent throwing when LatLng is non-finite#2182
JaffaKetchup merged 7 commits intofleaflet:masterfrom
monsieurtanuki:fix/2178

Conversation

@monsieurtanuki
Copy link
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
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
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
Contributor Author

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

@JaffaKetchup
Copy link
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
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
Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

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
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
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
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
Copy link
Member

JaffaKetchup commented Mar 1, 2026

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...

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