Skip to content
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

ios15环境下,同wifi下做本地调试,打开网页执行window.location.href 会破坏vite运行环境导致项目终止运行 #3850

Closed
jingxiaotian opened this issue Jun 18, 2021 · 2 comments · Fixed by #4223

Comments

@jingxiaotian
Copy link

只在ios15环境下,同wifi下调试,会出现此问题。
一旦执行window.location.href ,立马项目终止运行,其他版本ios 和 安卓手机都可以正常运行。
报错代码如下。

/Users/xxxxxxxxxxxxxxx/node_modules/vite/dist/node/chunks/dep-2c03f3f9.js:53050
else bu.unmask(buffer, mask);
^

TypeError: bu.unmask is not a function
at unmask (/Users/jingxiaotian/Documents/路径/node_modules/vite/dist/node/chunks/dep-2c03f3f9.js:53050:15)
at Receiver.getData (/Users/jingxiaotian/Documents/xxxxxxxxxxxxxxx/node_modules/vite/dist/node/chunks/dep-2c03f3f9.js:54012:25)
at Receiver.startLoop (/Users/jingxiaotian/Documents/路径/node_modules/vite/dist/node/chunks/dep-2c03f3f9.js:53808:22)
at Receiver._write (/Users/jingxiaotian/Documents/路径/node_modules/vite/dist/node/chunks/dep-2c03f3f9.js:53743:10)
at writeOrBuffer (_stream_writable.js:353:12)
at Receiver.Writable.write (_stream_writable.js:303:12)
at Socket.socketOnData (/Users/jingxiaotian/Documents/路径/node_modules/vite/dist/node/chunks/dep-2c03f3f9.js:55875:37)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:302:12)
at readableAddChunk (_stream_readable.js:278:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@0.0.0 dev: vite
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@0.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jingxiaotian/.npm/_logs/2021-06-18T02_33_54_321Z-debug.log

@github-actions
Copy link

Hello @jingxiaotian. Please provide a online reproduction by codesandbox or a minimal GitHub repository. Issues labeled by need reproduction will be closed if no activities in 3 days.

sodatea added a commit to sodatea/vite that referenced this issue Jul 12, 2021
Fixes vitejs#3977
Fixes vitejs#3850

😅 I've accidentally committed the actual fix in vitejs@25d86eb#diff-d17472499351c5bf75d44c67aaa203337dcce321fb578ff05302c61b2b2a3a8aR172

So this PR just removes the erroneous `ingoreDepPlugin`, and moves
the comments to the `ignore` option of the commonjs plugin.

The cause of the issues is this line: https://github.com/websockets/ws/blob/4c1849a61e773fe0ce016f6eb59bc3877f09aeee/lib/buffer-util.js#L105

When we ignore the optional deps when bundling, we expect
`require('bufferutil')` to throw an error.

However, with the previous `ignoreDepPlugin` implementation, the
`require` expression is turned into:
```js
var bufferutil = {
	__proto__: null
};

var require$$1 = /*@__PURE__*/getAugmentedNamespace(bufferutil);

// ...
const bufferUtil = require$$1;
```
No error is throwed, so the code executes into the wrong branch.

After the fix, the `require` expression is left as-is. As `bufferutil`
is not installed in the user project, the error is thrown as expected.
@github-actions
Copy link

This issue has been locked since it has been closed for more than 14 days.

If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants