Skip to content

Commit

Permalink
feat: support for Edge Functions debugging (#31)
Browse files Browse the repository at this point in the history
* feat: add support for Edge Functions debbugging via deno --inspect and --inspect-brk flags
  • Loading branch information
jackiewmacharia committed May 25, 2022
1 parent 0c4ff08 commit d69c79e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,21 @@ const prepareServer = ({
return startIsolate
}

interface InspectSettings {
// Inspect mode enabled
enabled: boolean

// Pause on breakpoints (i.e. "--brk")
pause: boolean

// Host/port override (optional)
address?: string
}
interface ServeOptions {
certificatePath?: string
debug?: boolean
distImportMapPath?: string
inspectSettings?: InspectSettings
importMaps?: ImportMapFile[]
onAfterDownload?: LifecycleHook
onBeforeDownload?: LifecycleHook
Expand All @@ -83,10 +94,12 @@ interface ServeOptions {
port: number
}

// eslint-disable-next-line complexity, max-statements
const serve = async ({
certificatePath,
debug,
distImportMapPath,
inspectSettings,
formatExportTypeError,
formatImportError,
importMaps,
Expand Down Expand Up @@ -122,6 +135,14 @@ const serve = async ({
flags.push('--quiet')
}

if (inspectSettings && inspectSettings.enabled) {
if (inspectSettings.pause) {
flags.push(inspectSettings.address ? `--inspect-brk=${inspectSettings.address}` : '--inspect-brk')
} else {
flags.push(inspectSettings.address ? `--inspect=${inspectSettings.address}` : '--inspect')
}
}

const server = await prepareServer({
deno,
distDirectory,
Expand Down

0 comments on commit d69c79e

Please sign in to comment.