You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When switching route on macOS (and possibly also iOS) Safari, the error "TypeError: bu.unmask is not a function" occurs, killing the vite server.
#3977
Closed
6 tasks done
shirakaba opened this issue
Jun 26, 2021
· 1 comment
· Fixed by #4223
In macOS Safari, when switching route (i.e. by clicking a link such <a sveltekit:prefetch="" href="/nouns-1-mora" class="s-Xvih31qJPb_c">1-mora nouns</a>, or by updating the URL bar manually), the error TypeError: bu.unmask is not a function appears, killing the dev server. The full error log is provided at the bottom of the issue.
As well as macOS Safari, the issue also appears to occur on iOS Safari, as seen by this duplicate issue that was closed due to lack of information: #3850. Of great note, it does not occur on macOS Firefox nor macOS Chrome on my system, so it seems to be a Safari-specific issue regarding missing functionality. Perhaps this unmask function does not exist on the buffer instance in Safari.
Curiously, however, whichever route is first loaded from the dev server will succeed; it's just that subsequent changes in route will not. So, just after starting the dev server, I could navigate to http://localhost:3000/nouns-1-mora just fine – but clicking links to navigate to another page like / would fail.
Reproduction
The repo https://github.com/shirakaba/jp-pitch-accent exhibits the issue. It was created using the SvelteKit CLI command npm init svelte@next jp-pitch-accent, and the changes relative to the starter template are minimal. To reproduce the issue, first clone the repo and get the Vite server running:
Setting up the repro
git clone git@github.com:shirakaba/jp-pitch-accent.git
cd jp-pitch-accent
npm install
npm run dev
Reproducing the error
Now visit http://localhost:3000 in macOS Safari. Click one of the links along the header (excluding the Twitter and GitHub links, which aren't locally served sites), such as "2-mora nouns" and you should see a view like below:
Note how, following the navigation action, the console now shows messages indicating failure to connect to the Vite server, and the GitHub and Twitter icons have become missing images. If you now view your Vite server, you will see that it has thrown an error and has exited prematurely.
System Info
Note that I am using the macOS Monterey beta. I can't recall whether or not I was experiencing the issue back on Catalina.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Provide a description in this issue that describes the bug.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
Though I can't reproduce this issue under macOS Big Sur, after looking into the generated code, I find that it is a bug caused by the ignoreDepPlugin in the build config.
Fixesvitejs#3977Fixesvitejs#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.
Describe the bug
In macOS Safari, when switching route (i.e. by clicking a link such
<a sveltekit:prefetch="" href="/nouns-1-mora" class="s-Xvih31qJPb_c">1-mora nouns</a>
, or by updating the URL bar manually), the errorTypeError: bu.unmask is not a function
appears, killing the dev server. The full error log is provided at the bottom of the issue.As well as macOS Safari, the issue also appears to occur on iOS Safari, as seen by this duplicate issue that was closed due to lack of information: #3850. Of great note, it does not occur on macOS Firefox nor macOS Chrome on my system, so it seems to be a Safari-specific issue regarding missing functionality. Perhaps this
unmask
function does not exist on the buffer instance in Safari.Curiously, however, whichever route is first loaded from the dev server will succeed; it's just that subsequent changes in route will not. So, just after starting the dev server, I could navigate to http://localhost:3000/nouns-1-mora just fine – but clicking links to navigate to another page like
/
would fail.Reproduction
The repo https://github.com/shirakaba/jp-pitch-accent exhibits the issue. It was created using the SvelteKit CLI command
npm init svelte@next jp-pitch-accent
, and the changes relative to the starter template are minimal. To reproduce the issue, first clone the repo and get the Vite server running:Setting up the repro
git clone git@github.com:shirakaba/jp-pitch-accent.git cd jp-pitch-accent npm install npm run dev
Reproducing the error
Now visit http://localhost:3000 in macOS Safari. Click one of the links along the header (excluding the Twitter and GitHub links, which aren't locally served sites), such as "2-mora nouns" and you should see a view like below:
Note how, following the navigation action, the console now shows messages indicating failure to connect to the Vite server, and the GitHub and Twitter icons have become missing images. If you now view your Vite server, you will see that it has thrown an error and has exited prematurely.
System Info
Note that I am using the macOS Monterey beta. I can't recall whether or not I was experiencing the issue back on Catalina.
Used package manager: npm
Logs
I apologise that I don't quite know how svelte-kit drives
vite
so I can't turn on the--debug
flag, but here are the debug logs I have access to:Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: