Skip to content

Commit 69f42bc

Browse files
committed
fix: improve logging of cloud connection (#888)
1 parent 120f688 commit 69f42bc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cloud.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export class XdebugCloudConnection extends EventEmitter {
2424

2525
private _dbgpConnection: DbgpConnection
2626

27+
private _logging = true
28+
2729
constructor(token: string, testSocket?: net.Socket) {
2830
super()
2931
if (testSocket != null) {
@@ -38,8 +40,13 @@ export class XdebugCloudConnection extends EventEmitter {
3840
this._rejectFn = null
3941
this._dbgpConnection = new DbgpConnection(this._tlsSocket)
4042

43+
this._dbgpConnection.on('log', (text: string) => {
44+
if (this._logging) {
45+
this.emit('log', text)
46+
}
47+
})
48+
4149
this._dbgpConnection.on('message', (response: XMLDocument) => {
42-
this.emit('log', response)
4350
if (response.documentElement.nodeName === 'cloudinit') {
4451
if (response.documentElement.firstChild && response.documentElement.firstChild.nodeName === 'error') {
4552
this._rejectFn?.(
@@ -57,8 +64,10 @@ export class XdebugCloudConnection extends EventEmitter {
5764
this._resolveFn?.()
5865
}
5966
} else if (response.documentElement.nodeName === 'init') {
67+
this._logging = false
6068
// spawn a new xdebug.Connection
6169
const cx = new xdebug.Connection(new InnerCloudTransport(this._tlsSocket))
70+
cx.once('close', () => (this._logging = true))
6271
cx.emit('message', response)
6372
this.emit('connection', cx)
6473
}

0 commit comments

Comments
 (0)