Skip to content

Commit

Permalink
Remove WebSocket debugger tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
arturpimentel committed Oct 25, 2023
1 parent f1e6bab commit 99c3b64
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 176 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed
- Websocket-based debugger tunnel;

### Changed
- Update `recommendedEdition` in `edition.ts to `[email protected]`

Expand Down
132 changes: 0 additions & 132 deletions src/modules/apps/debugger.ts

This file was deleted.

46 changes: 2 additions & 44 deletions src/modules/apps/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
validateAppAction,
} from '../../api/modules/utils'
import { createFlowIssueError } from '../../api/error/utils'
import { concat, intersection, isEmpty, map, pipe, prop } from 'ramda'
import { concat, isEmpty, map, pipe, prop } from 'ramda'
import { createInterface } from 'readline'
import { createPathToFileObject } from '../../api/files/ProjectFilesManager'
import { default as setup } from '../setup'
Expand All @@ -35,7 +35,6 @@ import debounce from 'debounce'
import log from '../../api/logger'
import moment from 'moment'
import retry from 'async-retry'
import startDebuggerTunnel from './debugger'
import workspaceUse from '../../api/modules/workspace/use'
import { BatchStream } from '../../api/typings/types'
import { Messages } from '../../lib/constants/Messages'
Expand All @@ -62,23 +61,12 @@ const INITIAL_LINK_CODE = 'initial_link_required'
const stabilityThreshold = process.platform === 'darwin' ? 100 : 200
const linkID = randomBytes(8).toString('hex')

const buildersToStartDebugger = ['node']
const buildersToRunLocalYarn = ['react', 'node']
const RETRY_OPTS_INITIAL_LINK = {
retries: 2,
minTimeout: 1000,
factor: 2,
}
const RETRY_OPTS_DEBUGGER = {
retries: 2,
minTimeout: 1000,
factor: 2,
}

const shouldStartDebugger = (manifest: ManifestEditor) => {
const buildersThatWillUseDebugger = intersection(manifest.builderNames, buildersToStartDebugger)
return buildersThatWillUseDebugger.length > 0
}

const performInitialLink = async (
root: string,
Expand Down Expand Up @@ -314,34 +302,6 @@ export async function appLink(options: LinkOptions) {
initial_link_required: () => warnAndLinkFromStart(root, projectUploader, unsafe),
}

let debuggerStarted = false
const onBuild = async () => {
if (debuggerStarted) {
return
}
const startDebugger = async () => {
const port = await startDebuggerTunnel(manifest)
if (!port) {
throw new Error('Failed to start debugger.')
}
return port
}
if (shouldStartDebugger(manifest)) {
try {
const debuggerPort = await retry(startDebugger, RETRY_OPTS_DEBUGGER)
// eslint-disable-next-line require-atomic-updates
debuggerStarted = true
log.info(
`Debugger tunnel listening on ${chalk.green(`:${debuggerPort}`)}. Go to ${chalk.blue(
'chrome://inspect'
)} in Google Chrome to debug your running application.`
)
} catch (e) {
log.error(e.message)
}
}
}

log.info(`Linking app ${appId}`)

let unlistenBuild
Expand All @@ -353,9 +313,7 @@ export async function appLink(options: LinkOptions) {
await listenBuild(subject, buildTrigger, { waitCompletion: true })
return
}
unlistenBuild = await listenBuild(subject, buildTrigger, { waitCompletion: false, onBuild, onError }).then(
prop('unlisten')
)
unlistenBuild = await listenBuild(subject, buildTrigger, { waitCompletion: false, onError }).then(prop('unlisten'))
} catch (e) {
if (e.response) {
const { data } = e.response
Expand Down

0 comments on commit 99c3b64

Please sign in to comment.