Unverified Commit 0e4fe2ff authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Code frame and sourcemapped error support for Turbopack (#56727)

This implements support for properly tracing sourcemaps when presenting
error stacks to the user. It also adds code frames when possible.


Closes WEB-1764

---------
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent a3aa6590
...@@ -3491,6 +3491,7 @@ dependencies = [ ...@@ -3491,6 +3491,7 @@ dependencies = [
"tracing-subscriber", "tracing-subscriber",
"turbo-tasks", "turbo-tasks",
"turbopack-binding", "turbopack-binding",
"url",
] ]
[[package]] [[package]]
......
...@@ -75,6 +75,7 @@ turbopack-binding = { workspace = true, features = [ ...@@ -75,6 +75,7 @@ turbopack-binding = { workspace = true, features = [
"__turbopack", "__turbopack",
"__turbopack_ecmascript_hmr_protocol", "__turbopack_ecmascript_hmr_protocol",
] } ] }
url = {workspace = true}
[target.'cfg(not(all(target_os = "linux", target_env = "musl", target_arch = "aarch64")))'.dependencies] [target.'cfg(not(all(target_os = "linux", target_env = "musl", target_arch = "aarch64")))'.dependencies]
turbopack-binding = { workspace = true, features = ["__turbo_tasks_malloc"] } turbopack-binding = { workspace = true, features = ["__turbo_tasks_malloc"] }
......
use std::{path::PathBuf, sync::Arc, time::Duration}; use std::{path::PathBuf, sync::Arc, time::Duration};
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, bail, Context, Result};
use napi::{ use napi::{
bindgen_prelude::External, bindgen_prelude::External,
threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode}, threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode},
...@@ -18,7 +18,10 @@ use tracing_subscriber::{ ...@@ -18,7 +18,10 @@ use tracing_subscriber::{
}; };
use turbo_tasks::{TransientInstance, TurboTasks, UpdateInfo, Vc}; use turbo_tasks::{TransientInstance, TurboTasks, UpdateInfo, Vc};
use turbopack_binding::{ use turbopack_binding::{
turbo::tasks_memory::MemoryBackend, turbo::{
tasks_fs::{FileContent, FileSystem},
tasks_memory::MemoryBackend,
},
turbopack::{ turbopack::{
cli_utils::{ cli_utils::{
exit::ExitGuard, exit::ExitGuard,
...@@ -28,11 +31,13 @@ use turbopack_binding::{ ...@@ -28,11 +31,13 @@ use turbopack_binding::{
}, },
core::{ core::{
error::PrettyPrintError, error::PrettyPrintError,
source_map::{GenerateSourceMap, Token},
version::{PartialUpdate, TotalUpdate, Update}, version::{PartialUpdate, TotalUpdate, Update},
}, },
ecmascript_hmr_protocol::{ClientUpdateInstruction, ResourceIdentifier}, ecmascript_hmr_protocol::{ClientUpdateInstruction, ResourceIdentifier},
}, },
}; };
use url::Url;
use super::{ use super::{
endpoint::ExternalEndpoint, endpoint::ExternalEndpoint,
...@@ -607,3 +612,125 @@ pub fn project_update_info_subscribe( ...@@ -607,3 +612,125 @@ pub fn project_update_info_subscribe(
}); });
Ok(()) Ok(())
} }
#[turbo_tasks::value]
#[derive(Debug)]
#[napi(object)]
pub struct StackFrame {
pub file: String,
pub method_name: Option<String>,
pub line: u32,
pub column: Option<u32>,
}
#[napi]
pub async fn project_trace_source(
#[napi(ts_arg_type = "{ __napiType: \"Project\" }")] project: External<ProjectInstance>,
frame: StackFrame,
) -> napi::Result<Option<StackFrame>> {
let turbo_tasks = project.turbo_tasks.clone();
let traced_frame = turbo_tasks
.run_once(async move {
let file = match Url::parse(&frame.file) {
Ok(url) => match url.scheme() {
"file" => url.path().to_string(),
_ => bail!("Unknown url scheme"),
},
Err(_) => frame.file.to_string(),
};
let Some(chunk_base) = file.strip_prefix(
&(format!(
"{}/{}",
project.container.project().await?.root_path,
project.container.project().dist_dir().await?
)),
) else {
// File doesn't exist within the dist dir
return Ok(None);
};
let chunk_path = format!(
"{}{}",
project
.container
.project()
.client_relative_path()
.await?
.path,
chunk_base
);
let path = project
.container
.project()
.client_root()
.fs()
.root()
.join(chunk_path);
let Some(generatable): Option<Vc<Box<dyn GenerateSourceMap>>> =
Vc::try_resolve_sidecast(project.container.get_versioned_content(path)).await?
else {
return Ok(None);
};
let map = generatable
.generate_source_map()
.await?
.context("Chunk is missing a sourcemap")?;
let token = map
.lookup_token(frame.line as usize, frame.column.unwrap_or(0) as usize)
.await?
.clone_value()
.context("Unable to trace token from sourcemap")?;
let Token::Original(token) = token else {
return Ok(None);
};
let Some(source_file) = token.original_file.strip_prefix("/turbopack/[project]/")
else {
bail!("Original file outside project")
};
Ok(Some(StackFrame {
file: source_file.to_string(),
method_name: token.name,
line: token.original_line as u32,
column: Some(token.original_column as u32),
}))
})
.await
.map_err(|e| napi::Error::from_reason(PrettyPrintError(&e).to_string()))?;
Ok(traced_frame)
}
#[napi]
pub async fn project_get_source_for_asset(
#[napi(ts_arg_type = "{ __napiType: \"Project\" }")] project: External<ProjectInstance>,
file_path: String,
) -> napi::Result<Option<String>> {
let turbo_tasks = project.turbo_tasks.clone();
let source = turbo_tasks
.run_once(async move {
let source_content = &*project
.container
.project()
.project_path()
.join(file_path.to_string())
.read()
.await?;
let FileContent::Content(source_content) = source_content else {
return Ok(None);
};
Ok(Some(source_content.content().to_str()?.to_string()))
})
.await
.map_err(|e| napi::Error::from_reason(PrettyPrintError(&e).to_string()))?;
Ok(source)
}
...@@ -255,13 +255,22 @@ impl ProjectContainer { ...@@ -255,13 +255,22 @@ impl ProjectContainer {
pub fn hmr_identifiers(self: Vc<Self>) -> Vc<Vec<String>> { pub fn hmr_identifiers(self: Vc<Self>) -> Vc<Vec<String>> {
self.project().hmr_identifiers() self.project().hmr_identifiers()
} }
#[turbo_tasks::function]
pub async fn get_versioned_content(
self: Vc<Self>,
file_path: Vc<FileSystemPath>,
) -> Result<Vc<Box<dyn VersionedContent>>> {
let this = self.await?;
Ok(this.versioned_content_map.get(file_path))
}
} }
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct Project { pub struct Project {
/// A root path from which all files must be nested under. Trying to access /// A root path from which all files must be nested under. Trying to access
/// a file outside this root will fail. Think of this as a chroot. /// a file outside this root will fail. Think of this as a chroot.
root_path: String, pub root_path: String,
/// A path where to emit the build outputs. next.config.js's distDir. /// A path where to emit the build outputs. next.config.js's distDir.
dist_dir: String, dist_dir: String,
...@@ -374,13 +383,18 @@ impl Project { ...@@ -374,13 +383,18 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) async fn node_root(self: Vc<Self>) -> Result<Vc<FileSystemPath>> { pub async fn dist_dir(self: Vc<Self>) -> Result<Vc<String>> {
Ok(Vc::cell(self.await?.dist_dir.to_string()))
}
#[turbo_tasks::function]
pub async fn node_root(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
let this = self.await?; let this = self.await?;
Ok(self.node_fs().root().join(this.dist_dir.to_string())) Ok(self.node_fs().root().join(this.dist_dir.to_string()))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn client_root(self: Vc<Self>) -> Vc<FileSystemPath> { pub fn client_root(self: Vc<Self>) -> Vc<FileSystemPath> {
self.client_fs().root() self.client_fs().root()
} }
...@@ -399,7 +413,7 @@ impl Project { ...@@ -399,7 +413,7 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) async fn client_relative_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> { pub async fn client_relative_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
let next_config = self.next_config().await?; let next_config = self.next_config().await?;
Ok(self.client_root().join(format!( Ok(self.client_root().join(format!(
"{}/_next", "{}/_next",
...@@ -411,7 +425,7 @@ impl Project { ...@@ -411,7 +425,7 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) async fn project_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> { pub async fn project_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
let this = self.await?; let this = self.await?;
let root = self.project_root_path(); let root = self.project_root_path();
let project_relative = this.project_path.strip_prefix(&this.root_path).unwrap(); let project_relative = this.project_path.strip_prefix(&this.root_path).unwrap();
......
...@@ -519,6 +519,13 @@ export interface HmrIdentifiers { ...@@ -519,6 +519,13 @@ export interface HmrIdentifiers {
identifiers: string[] identifiers: string[]
} }
export interface StackFrame {
file: string
methodName: string | null
line: number
column: number | null
}
export interface UpdateInfo { export interface UpdateInfo {
duration: number duration: number
tasks: number tasks: number
...@@ -540,6 +547,8 @@ export interface Project { ...@@ -540,6 +547,8 @@ export interface Project {
hmrIdentifiersSubscribe(): AsyncIterableIterator< hmrIdentifiersSubscribe(): AsyncIterableIterator<
TurbopackResult<HmrIdentifiers> TurbopackResult<HmrIdentifiers>
> >
getSourceForAsset(filePath: string): Promise<string | null>
traceSource(stackFrame: StackFrame): Promise<StackFrame | null>
updateInfoSubscribe(): AsyncIterableIterator<TurbopackResult<UpdateInfo>> updateInfoSubscribe(): AsyncIterableIterator<TurbopackResult<UpdateInfo>>
} }
...@@ -916,6 +925,14 @@ function bindingToApi(binding: any, _wasm: boolean) { ...@@ -916,6 +925,14 @@ function bindingToApi(binding: any, _wasm: boolean) {
return subscription return subscription
} }
traceSource(stackFrame: StackFrame): Promise<StackFrame | null> {
return binding.projectTraceSource(this._nativeProject, stackFrame)
}
getSourceForAsset(filePath: string): Promise<string | null> {
return binding.projectGetSourceForAsset(this._nativeProject, filePath)
}
updateInfoSubscribe() { updateInfoSubscribe() {
const subscription = subscribe<TurbopackResult<UpdateInfo>>( const subscription = subscribe<TurbopackResult<UpdateInfo>>(
true, true,
......
...@@ -85,10 +85,9 @@ export function getOriginalStackFrame( ...@@ -85,10 +85,9 @@ export function getOriginalStackFrame(
} }
if ( if (
!( source.file === '<anonymous>' ||
source.file?.startsWith('webpack-internal:') || source.file?.match(/^node:/) ||
source.file?.startsWith('file:') source.file?.match(/https?:\/\//)
)
) { ) {
return Promise.resolve({ return Promise.resolve({
error: false, error: false,
......
...@@ -6,6 +6,7 @@ import type { ...@@ -6,6 +6,7 @@ import type {
WrittenEndpoint, WrittenEndpoint,
ServerClientChange, ServerClientChange,
Issue, Issue,
Project,
} from '../../../build/swc' } from '../../../build/swc'
import type { Socket } from 'net' import type { Socket } from 'net'
import type { FilesystemDynamicRoute } from './filesystem' import type { FilesystemDynamicRoute } from './filesystem'
...@@ -97,6 +98,10 @@ import { ...@@ -97,6 +98,10 @@ import {
getSourceById, getSourceById,
parseStack, parseStack,
} from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' } from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware'
import {
getOverlayMiddleware,
createOriginalStackFrame as createOriginalTurboStackFrame,
} from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware-turbopack'
import { mkdir, readFile, writeFile, rename, unlink } from 'fs/promises' import { mkdir, readFile, writeFile, rename, unlink } from 'fs/promises'
import { PageNotFoundError } from '../../../shared/lib/utils' import { PageNotFoundError } from '../../../shared/lib/utils'
import { import {
...@@ -200,6 +205,7 @@ async function startWatcher(opts: SetupOpts) { ...@@ -200,6 +205,7 @@ async function startWatcher(opts: SetupOpts) {
} = {} } = {}
let hotReloader: NextJsHotReloaderInterface let hotReloader: NextJsHotReloaderInterface
let project: Project | undefined
if (opts.turbo) { if (opts.turbo) {
const { loadBindings } = const { loadBindings } =
...@@ -223,7 +229,7 @@ async function startWatcher(opts: SetupOpts) { ...@@ -223,7 +229,7 @@ async function startWatcher(opts: SetupOpts) {
opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 ||
opts.fsChecker.rewrites.fallback.length > 0 opts.fsChecker.rewrites.fallback.length > 0
const project = await bindings.turbo.createProject({ project = await bindings.turbo.createProject({
projectPath: dir, projectPath: dir,
rootPath: opts.nextConfig.experimental.outputFileTracingRoot || dir, rootPath: opts.nextConfig.experimental.outputFileTracingRoot || dir,
nextConfig: opts.nextConfig, nextConfig: opts.nextConfig,
...@@ -905,7 +911,7 @@ async function startWatcher(opts: SetupOpts) { ...@@ -905,7 +911,7 @@ async function startWatcher(opts: SetupOpts) {
} }
if (mapping.has(id)) return if (mapping.has(id)) return
const subscription = project.hmrEvents(id) const subscription = project!.hmrEvents(id)
mapping.set(id, subscription) mapping.set(id, subscription)
// The subscription will always emit once, which is the initial // The subscription will always emit once, which is the initial
...@@ -1077,12 +1083,13 @@ async function startWatcher(opts: SetupOpts) { ...@@ -1077,12 +1083,13 @@ async function startWatcher(opts: SetupOpts) {
await writeFontManifest() await writeFontManifest()
await writeLoadableManifest() await writeLoadableManifest()
const overlayMiddleware = getOverlayMiddleware(project)
const turbopackHotReloader: NextJsHotReloaderInterface = { const turbopackHotReloader: NextJsHotReloaderInterface = {
turbopackProject: project, turbopackProject: project,
activeWebpackConfigs: undefined, activeWebpackConfigs: undefined,
serverStats: null, serverStats: null,
edgeServerStats: null, edgeServerStats: null,
async run(req, _res, _parsedUrl) { async run(req, res, _parsedUrl) {
// intercept page chunks request and ensure them with turbopack // intercept page chunks request and ensure them with turbopack
if (req.url?.startsWith('/_next/static/chunks/pages/')) { if (req.url?.startsWith('/_next/static/chunks/pages/')) {
const params = matchNextPageBundleRequest(req.url) const params = matchNextPageBundleRequest(req.url)
...@@ -1103,6 +1110,9 @@ async function startWatcher(opts: SetupOpts) { ...@@ -1103,6 +1110,9 @@ async function startWatcher(opts: SetupOpts) {
.catch(console.error) .catch(console.error)
} }
} }
await overlayMiddleware(req, res)
// Request was not finished. // Request was not finished.
return { finished: undefined } return { finished: undefined }
}, },
...@@ -2177,47 +2187,59 @@ async function startWatcher(opts: SetupOpts) { ...@@ -2177,47 +2187,59 @@ async function startWatcher(opts: SetupOpts) {
!file?.includes('<anonymous>') !file?.includes('<anonymous>')
) )
let originalFrame, isEdgeCompiler
if (frame?.lineNumber && frame?.file) { if (frame?.lineNumber && frame?.file) {
const moduleId = frame.file!.replace( if (opts.turbo) {
/^(webpack-internal:\/\/\/|file:\/\/)/, try {
'' originalFrame = await createOriginalTurboStackFrame(
) project!,
const modulePath = frame.file.replace( frame
/^(webpack-internal:\/\/\/|file:\/\/)(\(.*\)\/)?/, )
'' } catch {}
) } else {
const moduleId = frame.file!.replace(
/^(webpack-internal:\/\/\/|file:\/\/)/,
''
)
const modulePath = frame.file.replace(
/^(webpack-internal:\/\/\/|file:\/\/)(\(.*\)\/)?/,
''
)
const src = getErrorSource(err as Error) const src = getErrorSource(err as Error)
const isEdgeCompiler = src === COMPILER_NAMES.edgeServer isEdgeCompiler = src === COMPILER_NAMES.edgeServer
const compilation = ( const compilation = (
isEdgeCompiler isEdgeCompiler
? hotReloader.edgeServerStats?.compilation ? hotReloader.edgeServerStats?.compilation
: hotReloader.serverStats?.compilation : hotReloader.serverStats?.compilation
)! )!
const source = await getSourceById( const source = await getSourceById(
!!frame.file?.startsWith(path.sep) || !!frame.file?.startsWith(path.sep) ||
!!frame.file?.startsWith('file:'), !!frame.file?.startsWith('file:'),
moduleId, moduleId,
compilation compilation
) )
const originalFrame = await createOriginalStackFrame({ try {
line: frame.lineNumber, originalFrame = await createOriginalStackFrame({
column: frame.column, line: frame.lineNumber,
source, column: frame.column,
frame, source,
moduleId, frame,
modulePath, moduleId,
rootDirectory: opts.dir, modulePath,
errorMessage: err.message, rootDirectory: opts.dir,
serverCompilation: isEdgeCompiler errorMessage: err.message,
? undefined serverCompilation: isEdgeCompiler
: hotReloader.serverStats?.compilation, ? undefined
edgeCompilation: isEdgeCompiler : hotReloader.serverStats?.compilation,
? hotReloader.edgeServerStats?.compilation edgeCompilation: isEdgeCompiler
: undefined, ? hotReloader.edgeServerStats?.compilation
}).catch(() => {}) : undefined,
})
} catch {}
}
if (originalFrame) { if (originalFrame) {
const { originalCodeFrame, originalStackFrame } = originalFrame const { originalCodeFrame, originalStackFrame } = originalFrame
......
...@@ -494,6 +494,21 @@ export async function ncc_next__react_dev_overlay(task, opts) { ...@@ -494,6 +494,21 @@ export async function ncc_next__react_dev_overlay(task, opts) {
}) })
.target('dist/compiled/@next/react-dev-overlay/dist') .target('dist/compiled/@next/react-dev-overlay/dist')
await task
.source(
relative(
__dirname,
require.resolve('@next/react-dev-overlay/dist/middleware-turbopack')
)
)
.ncc({
precompiled: false,
packageName: '@next/react-dev-overlay',
externals: overlayExternals,
target: 'es5',
})
.target('dist/compiled/@next/react-dev-overlay/dist')
await task await task
.source( .source(
relative( relative(
......
...@@ -48,6 +48,10 @@ declare module 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' { ...@@ -48,6 +48,10 @@ declare module 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' {
export * from '@next/react-dev-overlay/dist/middleware' export * from '@next/react-dev-overlay/dist/middleware'
} }
declare module 'next/dist/compiled/@next/react-dev-overlay/dist/middleware-turbopack' {
export * from '@next/react-dev-overlay/dist/middleware-turbopack'
}
declare module 'next/dist/compiled/@next/react-refresh-utils/dist/ReactRefreshWebpackPlugin' { declare module 'next/dist/compiled/@next/react-refresh-utils/dist/ReactRefreshWebpackPlugin' {
import m from '@next/react-refresh-utils/ReactRefreshWebpackPlugin' import m from '@next/react-refresh-utils/ReactRefreshWebpackPlugin'
export = m export = m
......
import type { IncomingMessage, ServerResponse } from 'http'
import type { StackFrame } from 'stacktrace-parser'
import type { ParsedUrlQuery } from 'querystring'
import type { OriginalStackFrameResponse } from './middleware'
import fs, { constants as FS } from 'fs/promises'
import url from 'url'
import { codeFrameColumns } from '@babel/code-frame'
import { launchEditor } from './internal/helpers/launchEditor'
interface Project {
getSourceForAsset(filePath: string): Promise<string | null>
traceSource(stackFrame: RustStackFrame): Promise<RustStackFrame | null>
}
interface RustStackFrame {
file: string
methodName: string | null
line: number
column: number | null
}
const currentSourcesByFile: Map<string, Promise<string | null>> = new Map()
async function batchedTraceSource(project: Project, frame: StackFrame) {
const file = frame.file
if (!file) {
return
}
const sourceFrame = await project.traceSource({
file,
methodName: frame.methodName,
line: frame.lineNumber ?? 0,
column: frame.column,
})
if (!sourceFrame) {
return
}
let source
// Don't show code frames for node_modules. These can also often be large bundled files.
if (!sourceFrame.file.includes('node_modules')) {
let sourcePromise = currentSourcesByFile.get(sourceFrame.file)
if (!sourcePromise) {
sourcePromise = project.getSourceForAsset(sourceFrame.file)
currentSourcesByFile.set(sourceFrame.file, sourcePromise)
setTimeout(() => {
// Cache file reads for 100ms, as frames will often reference the same
// files and can be large.
currentSourcesByFile.delete(sourceFrame.file)
}, 100)
}
source = await sourcePromise
}
return {
frame: {
file: sourceFrame.file,
lineNumber: sourceFrame.line,
column: sourceFrame.column,
methodName: sourceFrame.methodName ?? frame.methodName,
arguments: [],
},
source: source ?? null,
}
}
export async function createOriginalStackFrame(
project: Project,
frame: StackFrame
): Promise<OriginalStackFrameResponse | null> {
const traced = await batchedTraceSource(project, frame)
if (!traced) {
return null
}
return {
originalStackFrame: traced.frame,
originalCodeFrame:
traced.source === null || traced.frame.file.includes('node_modules')
? null
: codeFrameColumns(
traced.source,
{
start: {
line: traced.frame.lineNumber,
column: traced.frame.column ?? 0,
},
},
{ forceColor: true }
),
}
}
function stackFrameFromQuery(query: ParsedUrlQuery): StackFrame {
return {
file: query.file as string,
methodName: query.methodName as string,
arguments: query.arguments as string[],
lineNumber:
typeof query.lineNumber === 'string'
? parseInt(query.lineNumber, 10)
: null,
column:
typeof query.column === 'string' ? parseInt(query.column, 10) : null,
}
}
export function getOverlayMiddleware(project: Project) {
return async function (req: IncomingMessage, res: ServerResponse) {
const { pathname, query } = url.parse(req.url!, true)
if (pathname === '/__nextjs_original-stack-frame') {
const frame = stackFrameFromQuery(query)
let originalStackFrame
try {
originalStackFrame = await createOriginalStackFrame(project, frame)
} catch (e: any) {
res.statusCode = 500
res.write(e.message)
res.end()
return
}
if (originalStackFrame === null) {
res.statusCode = 404
res.write('Unable to resolve sourcemap')
res.end()
return
}
res.statusCode = 200
res.setHeader('Content-Type', 'application/json')
res.write(Buffer.from(JSON.stringify(originalStackFrame)))
res.end()
return
} else if (pathname === '/__nextjs_launch-editor') {
const frame = stackFrameFromQuery(query)
const filePath = frame.file?.toString()
if (filePath === undefined) {
res.statusCode = 400
res.write('Bad Request')
res.end()
return
}
const fileExists = await fs.access(filePath, FS.F_OK).then(
() => true,
() => false
)
if (!fileExists) {
res.statusCode = 204
res.write('No Content')
res.end()
return
}
try {
launchEditor(filePath, frame.lineNumber ?? 1, frame.column ?? 1)
} catch (err) {
console.log('Failed to launch editor:', err)
res.statusCode = 500
res.write('Internal Server Error')
res.end()
return
}
res.statusCode = 204
res.end()
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment