Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 9 additions & 1 deletion packages/sdk/src/server/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import { adapters } from "@rails/actioncable";
import * as WS from "ws";

declare global {
function addEventListener(type: string, listener: () => void): void

Check failure on line 8 in packages/sdk/src/server/async.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing semicolon
function removeEventListener(type: string, listener: () => void): void

Check failure on line 9 in packages/sdk/src/server/async.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing semicolon
}

export type ServerAsyncResponseManagerOpts = {
apiHost: string;
getOauthToken: () => Promise<AccessToken> | AccessToken;
Expand All @@ -16,12 +21,15 @@
constructor(opts: ServerAsyncResponseManagerOpts) {
super();
this.serverOpts = opts;
global.addEventListener = () => {}

Check failure on line 24 in packages/sdk/src/server/async.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unexpected empty arrow function

Check failure on line 24 in packages/sdk/src/server/async.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing semicolon
global.removeEventListener = () => {}

Check failure on line 25 in packages/sdk/src/server/async.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unexpected empty arrow function

Check failure on line 25 in packages/sdk/src/server/async.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing semicolon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix incorrect WebSocket adapter assignment

There's a potential bug in the WebSocket adapter assignment. The comparison operator == is used instead of the assignment operator =.

Apply this fix:

    if (typeof adapters.WebSocket === "undefined")
-     adapters.WebSocket == WS;
+     adapters.WebSocket = WS;

Also applies to: 26-27

🧰 Tools
🪛 eslint (1.23.1)

[error] 24-24: Unexpected empty arrow function.

(@typescript-eslint/no-empty-function)


[error] 24-25: Missing semicolon.

(@typescript-eslint/semi)


[error] 25-25: Unexpected empty arrow function.

(@typescript-eslint/no-empty-function)

if (typeof adapters.WebSocket === "undefined")
adapters.WebSocket == WS;
}

protected override async getOpts(): Promise<AsyncResponseManagerOpts> {
const token = await this.serverOpts.getOauthToken();
const oauthToken = await this.serverOpts.getOauthToken();
const token = oauthToken.token.access_token;
const projectId = await this.serverOpts.getProjectId();
return {
url: `wss://${this.serverOpts.apiHost}/websocket?oauth_token=${token}`,
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/server/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { program } from "commander";

const {
CLIENT_ID, CLIENT_SECRET, PROJECT_ID, API_HOST,
CLIENT_ID, CLIENT_SECRET, PROJECT_ID, API_HOST, ENVIRONMENT,
} = process.env;

if (!CLIENT_ID || !CLIENT_SECRET || !PROJECT_ID) {
Expand All @@ -17,6 +17,7 @@
},
projectId: PROJECT_ID,
apiHost: API_HOST,
environment: ENVIRONMENT === "production" ? "production" : "development",

Check failure on line 20 in packages/sdk/src/server/cli.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected newline between test and consequent of ternary expression

Check failure on line 20 in packages/sdk/src/server/cli.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected newline between consequent and alternate of ternary expression
});

program
Expand Down
Loading