Skip to content

Error opening map file that contains URI encoded symbols in file name #245

Description

@albertlaiuste

I ran into an issue where I generated source maps with tsc but after that Jest stopped working for me when trying to open a map file containing curly brackets {orderId}.js.map with error:

Error: An error occurred while trying to read the map file at %7BorderId%7D.js.map
Error: ENOENT: no such file or directory, open '.../build/api/routes/orders/%7BorderId%7D.js.map'
    at Object.readFileUtf8 (node:internal/fs/sync:25:18)
    at readFileSync (node:fs:441:19)
    at V8ToIstanbul._readFileFromDir (.../node_modules/v8-to-istanbul/lib/v8-to-istanbul.js:94:12)

In /lib/v8-to-istanbul.js, when I replaced

  _readFileFromDir(filename) {
    return readFileSync(resolve(dirname(this.path), filename), 'utf-8')
  }

with

  _readFileFromDir(filename) {
    return readFileSync(resolve(dirname(this.path), decodeURIComponent(filename)), 'utf-8')
  }

resolved this for me but I'm unsure of the impact of this change or if it is the correct implementation for this.

I didn't find any issue mentioning this on a quick glance so I thought I'd report on this here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions