Commit 11085b9
## What's the problem this PR addresses?
Fixes #6890
Fixes #6145
Node's
[implementation](https://github.com/nodejs/node/blob/94cbb7758282bf5db837412f7cb3698f17ac1af3/lib/internal/fs/promises.js#L648)
of `FileHandle#read` allows reading into `TypedArray`s and `DataView`s
(collectively known as `ArrayBufferView`s, and checks for them using
`ArrayBuffer.isView()`.
On the other hand, our implementation checks using `Buffer.isBuffer()`
and thus only allows `Buffer`. If an `ArrayBufferView` is given, it
treats them as an options bag and pass its `.buffer` (which is an
`ArrayBuffer`) as the sink to the backing fs. If the backing fs is
Node's native `fs` then it would throw.
## How did you fix it?
Allow `ArrayBufferView`s by checking with `ArrayBuffer.isView()` as in
Node's implementation.
Because the underlying `FakeFS` interface only allows `Buffer` (and
changing that would be a breaking change), a `Buffer` backed by the
`ArrayBufferView` is used. (Q: Should we make that change next major?)
Also un-vendored the TypeScript types if the exact same type is
available from `@types/node` along the way. AFAICT those were vendored
because those types wasn't available at first? \cc @merceyz
This fix should be orthogonal to #6919
## Checklist
<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.
<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
---------
Co-authored-by: Maël Nison <[email protected]>
1 parent a592371 commit 11085b9
File tree
7 files changed
+302
-110
lines changed- .yarn/versions
- packages
- acceptance-tests/pkg-tests-specs/sources/commands
- yarnpkg-fslib
- sources/patchFs
- tests
- fixtures
- yarnpkg-pnp/sources
7 files changed
+302
-110
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
47 | 21 | | |
48 | 22 | | |
49 | 23 | | |
| |||
133 | 107 | | |
134 | 108 | | |
135 | 109 | | |
136 | | - | |
137 | | - | |
138 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
139 | 113 | | |
140 | 114 | | |
141 | | - | |
142 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
143 | 124 | | |
144 | | - | |
145 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
146 | 130 | | |
147 | 131 | | |
148 | | - | |
| 132 | + | |
149 | 133 | | |
150 | 134 | | |
151 | 135 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
160 | 152 | | |
| 153 | + | |
161 | 154 | | |
| 155 | + | |
| 156 | + | |
162 | 157 | | |
163 | 158 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | 159 | | |
168 | 160 | | |
169 | 161 | | |
170 | 162 | | |
171 | 163 | | |
172 | 164 | | |
173 | 165 | | |
174 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
175 | 174 | | |
176 | 175 | | |
177 | 176 | | |
| |||
Binary file not shown.
0 commit comments