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

ERR_INTERNAL_ASSERTION when loading ESM from CJS after compiling with tsc #54923

Closed
weary-adventurer opened this issue Sep 13, 2024 · 1 comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs.

Comments

@weary-adventurer
Copy link

Version

v22.8.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

No response

What steps will reproduce the bug?

Compiling a TS file with tsc that uses both require and import produces something like this:

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const http_1 = __importDefault(require("http"));
const https_1 = __importDefault(require("https"));
const mmdb_lib_2_1_1_1 = __importDefault(require("../vendor/mmdb-lib-2.1.1"));
// Crashes here

Original TS file:

import fs from "fs";
import path from "path";
import http, { IncomingHttpHeaders, IncomingMessage } from "http";
import https from "https";
import MmdbLib from "../vendor/mmdb-lib-2.1.1";
// Rest of the file

My vendor structure is:

vendor
└───mmdb-lib-2.1.1
    │   index.d.ts
    │   index.js
    └───node_modules
        └───mmdb-lib (original mmdb-lib from npm here)

File ./vendor/mmdb-lib-2.1.1/index.js contains:

export * from "mmdb-lib";

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

No internal assertion should happen

What do you see instead?

Internal assertion happens:

node:internal/assert:14
    throw new ERR_INTERNAL_ASSERTION(message);
    ^

Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at assert (node:internal/assert:14:11)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:329:5)
    at new ModuleJobSync (node:internal/modules/esm/module_job:313:34)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:314:11)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1381:24)
    at Module._compile (node:internal/modules/cjs/loader:1503:5)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14) {
  code: 'ERR_INTERNAL_ASSERTION'

Additional information

No response

@RedYetiDev RedYetiDev closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2024
@RedYetiDev RedYetiDev added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Sep 13, 2024
@RedYetiDev
Copy link
Member

Duplicate of an existing report

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs.
Projects
None yet
Development

No branches or pull requests

2 participants