Skip to content

Commit

Permalink
fix: Proper handling of authentication error (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonsilberman authored Jul 26, 2019
1 parent c743277 commit 7d6baa9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
26 changes: 13 additions & 13 deletions packages/@best/runner-hub/src/HubClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ function proxifyRunner(benchmarkEntryBundle: BenchmarkInfo, projectConfig: Froze
socket.on('connect_error', (err: any) => {
console.log('Error in connection to agent > ', err);
reject(err);
})
});

socket.on('error', (err: any) => {
console.log('Error in connection to agent > ', err);
reject(err);
});

socket.on('connect', () => {
if (cancelledRun) {
Expand Down Expand Up @@ -109,11 +114,6 @@ function proxifyRunner(benchmarkEntryBundle: BenchmarkInfo, projectConfig: Froze
resolve(result);
});

socket.on('error', (err: any) => {
console.log('Error in connection to agent > ', err);
reject(err);
});

socket.emit('benchmark_task', {
benchmarkName,
benchmarkFolder,
Expand Down Expand Up @@ -160,15 +160,15 @@ export class HubClient {
console.log('Error in connection to agent > ', err);
resolved = true;
reject(err);
})
});

socket.on('connect', () => {
socket.on('error', (err: any) => {
console.log('Error in connection to agent > ', err);
resolved = true;
reject(err);
});
socket.on('error', (err: any) => {
console.log('Error in connection to agent > ', err);
resolved = true;
reject(err);
});

socket.on('connect', () => {
socket.on('disconnect', (reason: string) => {
if (!resolved) {
resolved = true;
Expand Down
15 changes: 10 additions & 5 deletions packages/@best/runner-remote/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ function proxifyRunner(benchmarkEntryBundle: BenchmarkInfo, projectConfig: Froze

const socket = socketIO(host, normalizedSocketOptions);

socket.on('connect_error', (err: any) => {
console.log('Error in connection to agent > ', err);
reject(err);
});

socket.on('error', (err: any) => {
console.log('Error in connection to agent > ', err);
reject(err);
});

socket.on('connect', () => {
socket.on('load_benchmark', () => {
const uploader = new SocketIOFile(socket);
Expand Down Expand Up @@ -70,11 +80,6 @@ function proxifyRunner(benchmarkEntryBundle: BenchmarkInfo, projectConfig: Froze
}
});

socket.on('error', (err: any) => {
console.log('Error in connection to agent > ', err);
reject(err);
});

socket.on('benchmark_error', (err: any) => {
console.log(err);
reject(new Error('Benchmark couldn\'t finish running. '));
Expand Down

0 comments on commit 7d6baa9

Please sign in to comment.