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

Maximum call stack when export the current file #1220

Closed
6 tasks done
pikax opened this issue May 1, 2022 · 0 comments · Fixed by #1221
Closed
6 tasks done

Maximum call stack when export the current file #1220

pikax opened this issue May 1, 2022 · 0 comments · Fixed by #1221

Comments

@pikax
Copy link
Contributor

pikax commented May 1, 2022

Describe the bug

Failing code:

import { describe, it, expect, vi } from "vitest";
import { dbContact } from "@judis/shared";

describe("contact spec", async () => {
  it("test", () => {
    try {
      const schema = dbContact(); // error here
    } catch (e) {
      console.error("sss", e);
    }
    expect(1).toBe(1);
  });
});

Error:

stderr | src/composables/validation.spec.ts > contact spec > tt
sss RangeError: Maximum call stack size exceeded
    at Module.get [as dbContact] (file:///C:/dev/untitled-advogado-project/node_modules/.pnpm/vitest@0.10.0_happy-dom@3.1.0+sass@1.51.0/node_modules/vitest/dist/chunk-vite-node-utils.33447cc0.js:9073:13)
    at Module.get [as dbContact] (file:///C:/dev/untitled-advogado-project/node_modules/.pnpm/vitest@0.10.0_happy-dom@3.1.0+sass@1.51.0/node_modules/vitest/dist/chunk-vite-node-utils.33447cc0.js:9073:32)
    at Module.get [as dbContact] (file:///C:/dev/untitled-advogado-project/node_modules/.pnpm/vitest@0.10.0_happy-dom@3.1.0+sass@1.51.0/node_modules/vitest/dist/chunk-vite-node-utils.33447cc0.js:9073:32)
    at Module.get [as dbContact] (file:///C:/dev/untitled-advogado-project/node_modules/.pnpm/vitest@0.10.0_happy-dom@3.1.0+sass@1.51.0/node_modules/vitest/dist/chunk-vite-node-utils.33447cc0.js:9073:32

Code throwing the call stack:

function exportAll(exports, sourceModule) {
  for (const key in sourceModule) {
    if (key !== "default") {
      try {
        Object.defineProperty(exports, key, {
          enumerable: true,
          configurable: true,
          get() {
            return sourceModule[key]; // here
          }
        });
      } catch (_err) {
      }
    }
  }
}

@judis/shared is a workspace dependency, it exports a nested dependency:

// @judis/shared/src/index.ts
export * from './db'

// @judis/shared/src/db.ts
export * from './firms'

// @judis/shared/firms/index.ts
export * from './contact'
export * from './index'

// @judis/shared/firms/contact.ts
export function dbContact(){
  console.log('it doesn't matter what the code is')
}

Reproduction

This happens when you export the current module

// mydep/index.ts
export * from './foo'
export * from './index' // error here

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 25.24 GB / 63.94 GB
  Binaries:
    Node: 16.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.13 - C:\Program Files\nodejs\yarn.CMD
    npm: 7.24.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (101.0.1210.32)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    vitest: ^0.10.0 => 0.10.0

Used Package Manager

pnpm

Validations

@pikax pikax changed the title Maximum call stack when importing a module Maximum call stack when export the current file May 1, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 19, 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.

1 participant