Using bun and express to run remix, I am running into an error with source-map-support
.
With code in express like
sourceMapSupport.install({
retrieveSourceMap: function (source) {
console.log(source, `${source}.map`)
return {
url: source,
map: fs.readFileSync(`${source}.map`, "utf8"),
}
},
})
to restore sourcemaps, I get the error:
/Users/dangoodman/code/sellmyai/build/index.js /Users/dangoodman/code/sellmyai/build/index.js.map
583 | if (aNeedle[aLineName] <= 0) {
584 | throw new TypeError('Line must be greater than or equal to 1, got '
585 | + aNeedle[aLineName]);
586 | }
587 | if (aNeedle[aColumnName] < 0) {
588 | throw new TypeError('Column must be greater than or equal to 0, got '
^
TypeError: Column must be greater than or equal to 0, got -1
at SourceMapConsumer_findMapping (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:588:13)
at SourceMapConsumer_originalPositionFor (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:653:17)
at mapSourcePosition (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:244:28)
at wrapCallSite (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:397:20)
at prepareStackTrace (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:446:39)
at new RowsNotFound (/Users/dangoodman/code/sellmyai/build/index.js:550:30)
at /Users/dangoodman/code/sellmyai/build/index.js:2490:11
at processTicksAndRejections (:61:77)
(omitting the retrieveSourceMap
option results in the same error)
I can confirm that the files exist at that location. My remix.config.js
looks like:
/** @type {import('@remix-run/dev').AppConfig} */
export default {
ignoredRouteFiles: ["**/.*"],
serverModuleFormat: "esm",
appDirectory: "src/remix",
};
I pull remix into bun like:
import * as build from "../build/index.js"
app.all("*", createRequestHandler({ build: build as any }))
and have the dev command: "remix dev --manual -c \"bun --watch run src/index.ts\""
The sources I get if I log (based on below comment):
/Users/dangoodman/code/sellmyai/build/index.js
/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js
/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js
full error:
/Users/dangoodman/code/sellmyai/build/index.js
583 | if (aNeedle[aLineName] <= 0) {
584 | throw new TypeError('Line must be greater than or equal to 1, got '
585 | + aNeedle[aLineName]);
586 | }
587 | if (aNeedle[aColumnName] < 0) {
588 | throw new TypeError('Column must be greater than or equal to 0, got '
^
TypeError: Column must be greater than or equal to 0, got -1
at SourceMapConsumer_findMapping (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:588:13)
at SourceMapConsumer_originalPositionFor (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:653:17)
at mapSourcePosition (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:244:28)
at wrapCallSite (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:397:20)
at prepareStackTrace (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:446:39)
at new RowsNotFound (/Users/dangoodman/code/sellmyai/build/index.js:550:30)
at /Users/dangoodman/code/sellmyai/build/index.js:2503:11
at processTicksAndRejections (:61:77)
/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js
/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js
586 | }
587 | if (aNeedle[aColumnName] < 0) {
588 | throw new TypeError('Column must be greater than or equal to 0, got '
589 | + aNeedle[aColumnName]);
590 | }
591 |
^
TypeError: Column must be greater than or equal to 0, got -1
at SourceMapConsumer_findMapping (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:591:69)
at SourceMapConsumer_originalPositionFor (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:662:10)
at mapSourcePosition (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:28:1)
at wrapCallSite (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:398:7)
at prepareStackTrace (/Users/dangoodman/code/sellmyai/node_modules/source-map-support/source-map-support.js:449:55)
at captureStackTrace (native:1:1)
at new RowsNotFound (/Users/dangoodman/code/sellmyai/src/remix/routes/dashboard.settings.tsx:302:13)
Error.captureStackTrace(this, this.constructor)
breaks when used in custom errors, otherwise all that is needed is:
import sourceMapSupport from "source-map-support"
sourceMapSupport.install()