-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Move read and write logic from nativeTextFileService to textFileService for #79275 #100804
Conversation
This would not be a good option going forward though. VSCode itself is exploring to enable a sandbox option from Electro that prevents any node.js code to be executed in the window. My hope was that the work you do can benefit both web and the future sandboxed desktop environment. I would want this solution to support all encodings in both web and sandboxed desktop if possible. If there is a reason we cannot support this for some encodings, we should understand why that is and come up with a custom solution if possible. I thought that
Yeah I think for desktop I would like to preserve that because it will test the actual stack down to the disk. However, we have a way to register file system providers and we could simply swap out the disk based provider with an in-memory one here: vscode/src/vs/workbench/services/textfile/test/electron-browser/textFileService.io.test.ts Line 54 in b8f63e9
In other words, all those tests could run fine in web if the file system provider registered is one that is in-memory for web. For example we have one here:
It cannot move currently due to:
|
Your assumption is correct. It's not about native dependencies, it's about
👍
Yeah, that's exactly what I am doing currently. Will adjust then to reuse the same tests in-between environments with different file services. |
Converting to draft, simply ping when I should give a review. |
@bpasero at last I am ready for the first full review! 🎉 |
Great, but as we enter endgame for June, this will slip to next week and July release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gyzerok overall this looks very good, I pushed few cosmetic changes via 82ca79b if you want to check.
Two things come to my mind though:
- running tests from your branch (even before my changes) results in a lot of test failures (via
yarn test-browser
). I cannot really explain that given the build also runs these tests and seems to be green. I ran them on macOS, do you see that too? - there seems to be a questionable check for
value
that does not account for the empty string [1]
Also going forward, would be great to add individual commits on top and not squash so that reviewing becomes easier 👍 |
@bpasero especially love your changes around timeout. They make code much more linear! Didn't know this function exists. I rebased on the latest master and made couple of fixes. By the way how do you make these cool code inline blocks in your comments?
Do the errors you are seeing look like assertion error between array converted to string and a string? If so this is due to Also I can clearly see exactly these tests passing in Azure. And there is no way they can pass in browser if My guess is as follows:
So I suggest you to check the Azure. If I am correct than it doesn't seem to me like a desired cache restoration behavior.
Haha, great catch! I feel ashamed by the errors I am making 😅 Huge thanks for your thorough reviews, which helps us find these oversights! 👍 |
👍 , I think even before you did call
You probably mean the code references. Simply open a file on GH, go to the line (you can even select multiple lines when you shift-click) and copy the "Permalink". If you paste a permalink into a comment, GH will show the sources.
I can check again, meanwhile can you make a
No worries, it was wise to do these changes through various PRs to keep the review at a manageable level 👍 |
I've already done that when fixing. It should work for you as well if you update the branch to the latest version. |
I’ve expected it to send each chunk in a separate event loop frame, but after the loop (current frame) is finished, yes. Can you widen my knowledge here? Why would they go all in a single frame? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed, works fine now, good job 👍 . Thanks a ton for making these tests run inside browser environment.
I am not an expert in what the browser internally does, so I was speculating that
In other words, awaiting in each iteration seems closer to reality, e.g. when comparing with disk IO. |
@gyzerok merged! I guess only missing now is to enable encoding related UI for web 🚀 |
…ce for microsoft#79275 (microsoft#100804) * move encoding logic from NativeTextFileService to AbstractTextFileService for microsoft#79275 * some cleanup things - just cosmetic * fix tests * review * use correct comparison Co-authored-by: Benjamin Pasero <benjpas@microsoft.com>
Hey @bpasero! Here comes 😄
This PR isn't finished yet. I am opening it to get your early feedback and to ask some questions.
What is blocking
Currently I am blocked by #79275 (comment). I've made a PR for
iconv-lite
to fix the issue and am currently awaiting the resolution.Also in case
iconv-lite
author will decide to reject my PR we can still proceed forward by allowing only subset of encodings in the browser for which we can ensureUint8Array
support by test coverage.Tests
I was looking into how I could run tests for
textFileService
inside browser as well.The problem there (as we discussed before) is that we can't load fixtures from files inside browser environment. So I figured I can pre-encode fixtures data and put it inside
ts
modules. Overall it worked great and even allowed me to discover an issue withjschardet
I've missed in my previous PR.I wrote the tests so that they repeat the same tests for
nativeTextFileService
exactly with the exception of the environment. So here comes options on which I seek your guidance:Is loading from file system crucial for us when testing
nativeTextFileService
?textFileService
which will run in both environmentsPersonally I like option 1 more. In my opinion we should test that
textFileService
works, not that the file system works. So in my mind loading fixtures from actual file system is not relevant for this tests.Other questions
It looks like
AbstractTextFileService
only uses what is defined incommon
, but itself is inbrowser
. Is it intentional? Should it be moved tocommon
?