-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
ajaxerror not serialized properly #4211
ajaxerror not serialized properly #4211
Conversation
…xtendend properties get lost
… test; note that jsdom Blob does not work with node native structuredClone so that one line is disabled
…age; e.g. AJAXError which already is registered for transfer but ignored because it's instance of Error
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4211 +/- ##
===========================================
- Coverage 87.75% 65.15% -22.60%
===========================================
Files 242 242
Lines 33082 33081 -1
Branches 2178 1427 -751
===========================================
- Hits 29032 21555 -7477
- Misses 3067 10701 +7634
+ Partials 983 825 -158 ☔ View full report in Codecov by Sentry. |
i had so much trouble with jsdom+structuredclone that i wrote a quick demo how it really behaves in browsers, might be helpful to understand what i did https://codepen.io/oberhamsi/pen/VwOpYqz hm, during manual testing i noticed problems with this approach. i'll wait for feedback but will probably handle the check in worker_transfer differently
|
Thanks for taking the time to look into this! |
thanks for the quick feedback! i'll keep working on it |
…d class, otherwise use the built-in to serialize/deserialize; fixes the issue that most Errors are (de)serialized by the builtin but AjaxError extend is not
i'll look into the tests. it's not due to the environment :/ |
…egistered class, otherwise use the built-in to serialize/deserialize; fixes the issue that most Errors are (de)serialized by the builtin but AjaxError extend is not" This reverts commit 5f378cd.
Co-authored-by: Harel M <[email protected]>
…ealistic test; note that jsdom Blob does not work with node native structuredClone so that one line is disabled" This reverts commit cbf397d.
…ides it since we don't want a custom jest env
The coverage of these methods wasn't great before you changed the code :-( |
i've added a few more tests and will keep looking into it. thanks again for the feedback. |
test coverage is now good but if you're not happy with the sweeping changes, what do you think about reverting the refactor? 7fd8cab you didn't like the duplication but they were (mostly) present before and i don't see how to make this significantly better without moving a few things, as i did. this is how it was before the refactor: https://github.com/orfon/maplibre-gl-js/blob/1374644017b439854a4bd1ab5246fe878fe27266/src/util/web_worker_transfer.ts maybe I can do the refactor once structureClone arrives in jsdom. this would make me feel a lot better about the unit tests. |
The coverage of the file is at about 78%, I would feel better if is was closer to 85-90%. |
It would also be great if we could solve the following comment:
I'm not sure how easy it would be to solve this though. StructArray are generated classes, so it might be easy to change the generation code? I don't know, might be out of scope for this PR. |
…e implementation is missing the ability to serialize/deserialize some valid objects which can probably be seralized/deserialized by primitives
regarding serialize. yeah, one thing i don't like about that logic is how implicit it is. imo the reverse is also true: the comment tells us only StructArray uses otherwise i think it's fine to have custom serialize/deserialize if an object needs special handling to get revived after a transfer. i think moving the StructArray.serialize/deserialize into web_transfer would not be an improvement. and it does need special handling. |
also wanted to mention again, that we should switch the tests to mock the transfer with structuredClone to properly test the code related to transferable |
Can you update the branch from main? I think the conflicts prevent it from running the CI, maybe... |
Looks good in general. |
i also checked the 4 lines in main not covered by the new tests. two of them are still not covered because i don't think they can be triggered one is covered once refactored (okay, semi-great). and one line is now removed because of the new Error handling. |
Are you sure about the coverage?
|
yeah, that's odd. i'll investigate. some of the lines CI says are not covered, i'm certain they should be hit by the test. |
okay this is a fun one. node 20.10 has a coverage bug jestjs/jest#14766 nodejs/node#51251 if i downgrade to node 20.9 the test coverage for web_worker_transfer is correct. the test coverage for a lot of other files is also different with 20.9 my screenshots where from a run with i would suggest a different MR and switch to codeCoverage=babel. the only benefit of v8 would be speed. |
We are using a special coverage report tool due to the differences between browser test coverage (render tests) and unit test. |
the reporting is fine but the coverage reported by node is just wrong in 20.10 i would suggest switching to babel coverageReporter instead of v8, which is a simple change and the default used by jest anyways. i don't see a reason to use v8 expect for speed. |
These are the relevant PR related to this topic, I honestly don't understand all the details, I just want it to work...
Feel free to create a different PR to do the switch. |
I will look into it but probably mid july |
What do you suggest to do? I think general fixes to coverage can wait for a different PR and there's no need to hold this PR hostage... |
honestly i haven't worked with jest coverage before, so i don't know how to fix it just for this test. looking at the jest-docs yesterday, and trying different things, i feel changing this line to btw: thanks for all the guidance & hints! i'm really interested in getting this MR done - our current workaround involves |
@cenfun any insight regarding the above issue with the coverage? Do you have any tips? |
I don't think it will work if we merge babel coverage (unit test ) with v8 coverage (e2e test). This is why we use Jest v8 coverage providor. It's been a month already, It seems like it hasn't been fixed, whether it's Nodejs or Jest. |
Thanks for the quick reply @cenfun! I'll merge this and hope the fix will merged soon... |
fixes #4024
the original cause for
load
not firing was thatsource_cache
did not see the 404 returned by a failed tile request here https://github.com/maplibre/maplibre-gl-js/blob/main/src/source/source_cache.ts#L172this was caused by AjaxError no longer being serialized since commit d68b919#diff-0c7952cb97b3abe689d267fa5663ac8d387fbd6a637905cce9581a5cc2f1ff1c AjaxError is registered for transfer serialization but it's also an instance of Error and was thus just returned
i think the worker_transfer tests are better if they use
structuredClone
. this works for the other tests too but not for the once check againstBlob
- seems to be a bug with jsdoms customBlob
in combination with nodes nativestructuredClone
. i'm hoping this will be fixed with jsdom/jsdom#3363if you don't like the rather big change to the tests i can revert this and not do any tests for this issue.
Launch Checklist
CHANGELOG.md
under the## main
section.