-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix(socket): reconnection for websocket replacing in the process #100
Conversation
… heartbeat timeout
} | ||
|
||
private onSocketMessage(event) { | ||
const message = this.serializer.decode(event) |
Check notice
Code scanning / CodeQL
Semicolon insertion Note
the enclosing function
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 7 days ago
To fix the problem, we need to add an explicit semicolon at the end of the line const message = this.serializer.decode(event)
. This change will ensure that the code adheres to the recommended practice of using explicit semicolons and maintains consistency with the rest of the code in the function.
-
Copy modified line R118
@@ -117,3 +117,3 @@ | ||
private onSocketMessage(event) { | ||
const message = this.serializer.decode(event) | ||
const message = this.serializer.decode(event); | ||
if (!this.isActive && message.event == "AuthOk") { |
…actor and update example
…bia/async-dataflow into fix/socket-reconnection
}); | ||
}) |
Check notice
Code scanning / CodeQL
Semicolon insertion Note test
the enclosing function
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to add an explicit semicolon at the end of the statement on line 189. This will ensure consistency with the rest of the codebase and prevent any unintended behavior due to JavaScript's automatic semicolon insertion.
- Locate the statement on line 189 in the file
clients/client-js/test/async-client.test.ts
. - Add a semicolon at the end of the statement to make it explicit.
-
Copy modified line R189
@@ -188,3 +188,3 @@ | ||
}); | ||
}) | ||
}); | ||
|
import { ChannelMessage } from "../../src/channel-message"; | ||
import { SseTransport } from "../../src/transport"; | ||
import "fast-text-encoding" | ||
import { managedObservable, promiseFromObservable, timeout, waitFor } from '../utils/types.utils'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 7 days ago
To fix the problem, we need to remove the unused imports timeout
and waitFor
from the import statement on line 9. This will clean up the code and eliminate any confusion regarding unused imports.
- Remove
timeout
andwaitFor
from the import statement on line 9. - Ensure that the remaining imports in the statement are still correctly used in the code.
-
Copy modified line R9
@@ -8,3 +8,3 @@ | ||
import "fast-text-encoding" | ||
import { managedObservable, promiseFromObservable, timeout, waitFor } from '../utils/types.utils'; | ||
import { managedObservable, promiseFromObservable } from '../utils/types.utils'; | ||
|
let config: AsyncConfig = { | ||
socket_url: "ws://localhost:3000", | ||
channel_ref: "channel-1", | ||
channel_secret: "token-1", |
Check failure
Code scanning / CodeQL
Hard-coded credentials Critical test
authorization header
let config: AsyncConfig = { | ||
socket_url: "ws://localhost:3000", | ||
channel_ref: "channel-2", | ||
channel_secret: "token-2", |
Check failure
Code scanning / CodeQL
Hard-coded credentials Critical test
authorization header
let config: AsyncConfig = { | ||
socket_url: "ws://localhost:3000", | ||
channel_ref: "channel-3", | ||
channel_secret: "token-3", |
Check failure
Code scanning / CodeQL
Hard-coded credentials Critical test
authorization header
managed = managedObservable(); | ||
mockServer = new Server(`${config.socket_url}/ext/socket`); | ||
client = WsTransport.create(config, managed.onMessage, managed.onError, WebSocket); | ||
}) |
Check notice
Code scanning / CodeQL
Semicolon insertion Note test
the enclosing function
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 7 days ago
To fix the problem, we need to add an explicit semicolon at the end of the statement on line 30. This will ensure consistency with the rest of the code and prevent any potential issues caused by automatic semicolon insertion.
- Add a semicolon at the end of the statement on line 30 in the file
clients/client-js/test/transport/ws-transport.test.ts
.
-
Copy modified line R30
@@ -29,3 +29,3 @@ | ||
client = WsTransport.create(config, managed.onMessage, managed.onError, WebSocket) as WsTransport; | ||
}) | ||
}); | ||
|
} else if (new String(data).startsWith('Auth::')) { | ||
// @ts-ignore | ||
console.log("server. invalid credentials"); | ||
mockServer.close({ code: 4403, reason: "Invalid auth", wasClean: true }) |
Check notice
Code scanning / CodeQL
Semicolon insertion Note test
the enclosing function
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 7 days ago
To fix the problem, we need to add an explicit semicolon at the end of the mockServer.close
statement. This will ensure that the statement is correctly terminated and prevent any potential issues related to automatic semicolon insertion.
- Locate the
mockServer.close
statement on line 276 in the fileclients/client-js/test/transport/ws-transport.test.ts
. - Add a semicolon at the end of the statement to explicitly terminate it.
-
Copy modified line R276
@@ -275,3 +275,3 @@ | ||
console.log("server. invalid credentials"); | ||
mockServer.close({ code: 4403, reason: "Invalid auth", wasClean: true }) | ||
mockServer.close({ code: 4403, reason: "Invalid auth", wasClean: true }); | ||
} |
const result = await waitFor(connected); | ||
assert.equal(result, true); | ||
return client.getDecoder(); | ||
} |
Check notice
Code scanning / CodeQL
Semicolon insertion Note test
the enclosing function
res.write(`data: ${event}\n\n`); | ||
} | ||
|
||
console.log(`SSEMockServer: ${req.method} ${req.url}`); |
Check warning
Code scanning / CodeQL
Log injection Medium test
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to sanitize the user input before logging it. Specifically, we should remove any newline characters from req.url
and req.method
to prevent log injection attacks. This can be done using the String.prototype.replace
method to strip out any newline characters.
We will modify the logging statement on line 13 to sanitize req.method
and req.url
before logging them. This ensures that any malicious input is neutralized before it can affect the log entries.
-
Copy modified lines R13-R15
@@ -12,3 +12,5 @@ | ||
|
||
console.log(`SSEMockServer: ${req.method} ${req.url}`); | ||
const sanitizedMethod = req.method?.replace(/\n|\r/g, ""); | ||
const sanitizedUrl = req.url?.replace(/\n|\r/g, ""); | ||
console.log(`SSEMockServer: ${sanitizedMethod} ${sanitizedUrl}`); | ||
const mockResponse = SSEMockServer.getMock(req.url!); |
@@ -4,6 +4,8 @@ | |||
import { Subject } from 'rxjs'; | |||
import { Message } from '../models/message.inteface'; | |||
import { environment } from '../environments/environment'; | |||
import { SettingsService } from './settings.service'; | |||
import { U } from '@angular/cdk/keycodes'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to remove the unused import statement from the file. This will make the code cleaner and eliminate any confusion about the usage of U
. The change should be made in the file examples/front-async-angular/src/app/services/async-client.service.ts
by removing the line that imports U
from @angular/cdk/keycodes
.
-
Copy modified line R8
@@ -7,3 +7,3 @@ | ||
import { SettingsService } from './settings.service'; | ||
import { U } from '@angular/cdk/keycodes'; | ||
|
||
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
|
Description
Replace socket when a new socket connection is authenticated, update examples
Category
Checklist