Commit 7667838
Fix worker-test and
Summary:
The CircleCI build of metro is currently failing because `jest` fails to mock the `console` module. This is because the typeof console changed in the latest node version ([PR](nodejs/node#35399)). Meaning that the typeof `console` is `console` and Jest doesn't know how to mock a value of type `console`.
This diff manually mocks the `console` object to avoid this issue (verified with using Node 15 locally). However, the tests then started failing because the `close` event of streams was emitted more than once by our memory fs implementation.
The issue is that our `createWriteStream` implementetion does not specify the `emitClose: false` when creating the stream as required according to the [docs](https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options):
> By default, the stream will not emit a 'close' event after it has been destroyed. This is the opposite of the default for other Writable streams. Set the emitClose option to true to change this behavior.
I changed that in our `memory-fs` implementation and removed the manual emit of the `close` event. I then had to change the tests because the order of the events is `end`, `finish`, `close` and the tests asserted in the `end` event.
The tests then started passing on Node 15 but, surprise, they now failed on Node 12...
The reason is that the [`stream.Writeable`](https://nodejs.org/docs/latest-v13.x/api/stream.html#stream_constructor_new_stream_writable_options) option `autoDestroy` has changed with Node13 from default false to default true. Hardcoding `default: true` finally makes all tests passing on Node 12 - 15.
Reviewed By: cpojer
Differential Revision: D25495034
fbshipit-source-id: fdf871fa4dfbec079bc9ec1843fcff7facb3e0befs.createWriteStream spec incompliance1 parent 663621c commit 7667838
3 files changed
Lines changed: 19 additions & 17 deletions
File tree
- packages
- buck-worker-tool/src/__tests__
- metro-memory-fs/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
124 | | - | |
125 | 127 | | |
126 | | - | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | 141 | | |
143 | | - | |
144 | 142 | | |
145 | 143 | | |
146 | 144 | | |
147 | | - | |
148 | 145 | | |
149 | 146 | | |
150 | 147 | | |
| |||
154 | 151 | | |
155 | 152 | | |
156 | 153 | | |
157 | | - | |
158 | 154 | | |
159 | | - | |
160 | 155 | | |
161 | 156 | | |
162 | 157 | | |
163 | | - | |
164 | 158 | | |
165 | 159 | | |
166 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
| 1030 | + | |
1030 | 1031 | | |
1031 | 1032 | | |
1032 | 1033 | | |
| |||
1037 | 1038 | | |
1038 | 1039 | | |
1039 | 1040 | | |
| 1041 | + | |
1040 | 1042 | | |
1041 | 1043 | | |
1042 | 1044 | | |
1043 | 1045 | | |
1044 | 1046 | | |
1045 | 1047 | | |
1046 | 1048 | | |
1047 | | - | |
| 1049 | + | |
1048 | 1050 | | |
1049 | | - | |
| 1051 | + | |
1050 | 1052 | | |
1051 | 1053 | | |
1052 | 1054 | | |
1053 | 1055 | | |
1054 | 1056 | | |
1055 | 1057 | | |
1056 | 1058 | | |
1057 | | - | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
1058 | 1066 | | |
1059 | 1067 | | |
1060 | 1068 | | |
1061 | 1069 | | |
1062 | 1070 | | |
1063 | | - | |
1064 | 1071 | | |
1065 | 1072 | | |
1066 | 1073 | | |
| |||
1570 | 1577 | | |
1571 | 1578 | | |
1572 | 1579 | | |
| 1580 | + | |
1573 | 1581 | | |
1574 | 1582 | | |
1575 | | - | |
| 1583 | + | |
1576 | 1584 | | |
1577 | 1585 | | |
1578 | 1586 | | |
| |||
0 commit comments