Bun Compatibility with source-map-support: TypeError: Column must be greater than or equal to 0, got -1
#8482
-
Bun version 1.0.21+837cbd60d, macos x64 take the import { cssBundleHref } from "@remix-run/css-bundle";
import type { LinksFunction } from "@remix-run/node";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";
export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
];
export class RowsNotFound extends Error {
constructor() {
super("rows not found")
// capturing the stack trace keeps the reference to your error class
Error.captureStackTrace(this, this.constructor)
}
}
export async function yeh() {
throw new RowsNotFound()
}
export async function loader() {
await yeh()
return null
}
export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
} and run it from an express server like: import * as dotenv from 'dotenv'
dotenv.config()
import express from 'express'
import { v4 as uuidv4 } from 'uuid'
import cors from 'cors'
import { createRequestHandler } from "@remix-run/express"
import { broadcastDevReady } from "@remix-run/node"
import * as build from "build/index.js"
import sourceMapSupport from "source-map-support"
sourceMapSupport.install({
retrieveSourceMap: function (source) {
const match = source.startsWith("file://")
if (match) {
const filePath = url.fileURLToPath(source)
const sourceMapPath = `${filePath}.map`
if (fs.existsSync(sourceMapPath)) {
return {
url: source,
map: fs.readFileSync(sourceMapPath, "utf8"),
}
}
}
return null
},
})
// sourceMapSupport.install() // also fails
const listenPort = process.env.PORT || '8080'
async function main() {
const app = express()
app.use(express.json())
app.disable('x-powered-by')
app.use(cors())
// Remix public
app.use(express.static("public"))
app.get('/hc', (req, res) => {
res.sendStatus(200)
})
// Everything else we send to the frontend
app.all("*", createRequestHandler({ build: build as any }))
const server = app.listen(listenPort, () => {
if (process.env.NODE_ENV === "development") {
broadcastDevReady(build as any)
}
logger.info(`API listening on port ${listenPort}`)
})
let stopping = false
process.on('SIGTERM', async () => {
if (!stopping) {
stopping = true
logger.warn('Received SIGTERM command, shutting down...')
server.close()
logger.info('exiting...')
process.exit(0)
}
})
process.on('SIGINT', async () => {
if (!stopping) {
stopping = true
logger.warn('Received SIGINT command, shutting down...')
server.close()
logger.info('exiting...')
process.exit(0)
}
})
}
main() I run into the error when throwing an error:
You can see that some of the stack trace actually works (you can see my tsx files in the trace), but there is something up with this columns thing. Seems to work fine in the root The sources I get if I log (based on below comment):
full error:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
import sourceMapSupport from "source-map-support"
sourceMapSupport.install() works fine when that capture stack trace line is removed |
Beta Was this translation helpful? Give feedback.
-
Fixed in oven-sh/bun#8657 |
Beta Was this translation helpful? Give feedback.
Error.captureStackTrace(this, this.constructor)
breaks in Bunworks fine when that capture stack trace line is removed