Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WebSocket debugger tunnel #1200

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion src/api/modules/workspace/common/edition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ const promptSwitchEdition = (currEditionId: string) => {
recommendedEdition
)}.`
)
log.warn(`For more information about editions, check ${chalk.blue('https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-edition-app')}`)
log.warn(
`For more information about editions, check ${chalk.blue(
'https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-edition-app'
)}`
)
return promptConfirm(`Would you like to change the edition to ${chalk.blue(recommendedEdition)} now?`, false)
}

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
Loading