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

0.26.0 causes TypeError: __vite_ssr_import_1__.default.fileURLToPath is not a function #2531

Closed
6 tasks done
NathanVss opened this issue Dec 19, 2022 · 6 comments · Fixed by #2538
Closed
6 tasks done

Comments

@NathanVss
Copy link

Describe the bug

The upgrade from 0.25.7 to 0.26.0 causes this crash when running vitest run

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: __vite_ssr_import_1__.default.fileURLToPath is not a function
 ❯ ../../node_modules/vitest/dist/chunk-utils-env.03f840f2.js:256:64
    255| const defaultPort = 51204;
    256| const EXIT_CODE_RESTART = 43;
    257| const API_PATH = "/__vitest_api__";
       |                                  ^
    258| const configFiles = [
    259|   "vitest.config.ts",
 ❯ VitestRunner.directRequest ../../node_modules/vite-node/dist/client.mjs:283:5
 ❯ VitestRunner.cachedRequest ../../node_modules/vite-node/dist/client.mjs:146:14
 ❯ VitestRunner.dependencyRequest ../../node_modules/vite-node/dist/client.mjs:181:14
 ❯ async /node_modules/vitest/dist/chunk-typecheck-constants.3f865d14.js:3:31
 ❯ VitestRunner.directRequest ../../node_modules/vite-node/dist/client.mjs:283:5
 ❯ VitestRunner.cachedRequest ../../node_modules/vite-node/dist/client.mjs:146:14
 ❯ VitestRunner.dependencyRequest ../../node_modules/vite-node/dist/client.mjs:181:14
 ❯ async .../node_modules/vitest/dist/entry.js:3:31
 ❯ VitestRunner.directRequest ../../node_modules/vite-node/dist/client.mjs:283:5

Reproduction

Upgrading to 0.26.0

System Info

System:
    OS: macOS 13.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 280.63 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.19.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.3 - /usr/local/bin/npm
  Browsers:
    Chrome: 108.0.5359.124
    Safari: 16.1

Used Package Manager

yarn

Validations

@danez
Copy link
Contributor

danez commented Dec 19, 2022

I have the same problem!
Here is a minimal repro: https://github.com/danez-labs/vitest-import-url

This happens when the url package is installed in the project.
https://www.npmjs.com/package/url

@SirZach
Copy link

SirZach commented Dec 19, 2022

Been trying to fix this all morning. I noticed if I added

console.log(url.fileURLToPath)

to the node_modules/vitest/dist/chunk-utils-env.<build number>.js file, the log output goes back and forth between logging

[Function: fileURLToPath]

and undefined. Going back to version 0.25.7 fixes the issue.

@sheremet-va
Copy link
Member

You should be able to fix this temporary by enabling deps.interopDefault. I will look into why this doesn't work natively tomorrow.

@SirZach
Copy link

SirZach commented Dec 19, 2022

Added to my vitest.config.ts file

/// <reference types="vitest" />

import { defineConfig } from "vite";

export default defineConfig({
  test: {
    globals: true,
    environment: "happy-dom",
    deps: {
      interopDefault: true,
    },
  },
});

But getting the same error

@ffxsam
Copy link

ffxsam commented Dec 20, 2022

Same issue here. Reverting to 0.25.7 fixes this.

@betabandido
Copy link

betabandido commented Dec 20, 2022

Enabling deps.interopDefault doesn't work for me either. And, I cannot revert to 0.25, since 0.26 fixed an issue when importing default exports from some dependencies.

Here is my reproducible example: https://stackblitz.com/edit/vitest-dev-vitest-qu86fl

NathanVss added a commit to openfun/cunningham that referenced this issue Dec 20, 2022
Vitest 0.26.0 was causing crashes during tests. I posted an issue here
vitest-dev/vitest#2531
NathanVss added a commit to openfun/cunningham that referenced this issue Dec 22, 2022
Vitest 0.26.0 was causing crashes during tests. I posted an issue here
vitest-dev/vitest#2531
@github-actions github-actions bot locked and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants