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

websocket errors/warnings in frontend/ tests #2753

Open
illume opened this issue Jan 17, 2025 · 1 comment
Open

websocket errors/warnings in frontend/ tests #2753

illume opened this issue Jan 17, 2025 · 1 comment
Labels
bug Something isn't working frontend Issues related to the frontend multi Multi cluster aggregated view

Comments

@illume
Copy link
Collaborator

illume commented Jan 17, 2025

There are some websocket errors/warnings when running the frontend tests.

To Reproduce

Run frontend tests (npm test) and see websocket errors.

Additional Context

It would be good to know if these were in the last release, or if they are new.

@illume illume added bug Something isn't working multi Multi cluster aggregated view labels Jan 17, 2025
@dosubot dosubot bot added the frontend Issues related to the frontend label Jan 17, 2025
@knrt10
Copy link
Contributor

knrt10 commented Jan 17, 2025

There are 2 type of errors. The old one's which is expected as this uses old API. We do not need to fix it.

stderr | src/lib/k8s/api/v1/apiProxy.test.ts > apiProxy > streamResults, streamResultsForCluster > streamResultsForCluster > Successfully handles ADDED, MODIFIED, and DELETED types
Socket closed unexpectedly {
  path: '/apis/v1/namespaces/default/configmaps?watch=1&resourceVersion=1234',
  args: [
    CloseEvent {
      type: 'close',
      timeStamp: 1737088349587,
      target: [WebSocket],
      srcElement: [WebSocket],
      returnValue: true,
      isTrusted: false,
      eventPhase: 0,
      defaultPrevented: false,
      currentTarget: [WebSocket],
      cancelable: false,
      cancelBubble: false,
      bubbles: false,
      code: 1000,
      reason: '',
      wasClean: true
    }
  ]
}

The new one's that used v2 API are fixed. Creating a PR for the same

2nd one is

stderr | src/storybook.test.tsx > Storybook Tests > WebhookConfiguration/ValidatingWebhookConfig/Details > WithURL
WebSocket error: Event { isTrusted: [Getter] }
WebSocket connection failed: Error: WebSocket connection failed
    at WebSocket.socket.onerror (/Users/kautilya/dev/microsoft/headlamp/frontend/src/lib/k8s/api/v2/webSocket.ts:153:16)
    at WebSocket.invokeTheCallbackFunction (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js:14:28)
    at WebSocket.<anonymous> (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:35:32)
    at innerInvokeEventListeners (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25)
    at invokeEventListeners (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3)
    at WebSocketImpl._dispatch (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9)
    at fireAnEvent (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36)
    at WebSocketImpl._onConnectionClosed (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/websockets/WebSocket-impl.js:233:7)
    at WebSocket.<anonymous> (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/jsdom/lib/jsdom/living/websockets/WebSocket-impl.js:144:14)
    at Object.onceWrapper (node:events:626:26)
    at WebSocket.emit (node:events:511:28)
    at WebSocket.emitClose (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/ws/lib/websocket.js:262:12)
    at emitErrorAndClose (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/ws/lib/websocket.js:1042:13)
    at ClientRequest.<anonymous> (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/ws/lib/websocket.js:881:5)
    at ClientRequest.emit (node:events:511:28)
    at MockHttpSocket.socketErrorListener (node:_http_client:495:9)
    at MockHttpSocket.emit (node:events:523:35)
    at MockHttpSocket.emit (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/MockHttpSocket.ts:135:12)
    at Socket.<anonymous> (/Users/kautilya/dev/microsoft/headlamp/frontend/node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/MockHttpSocket.ts:251:14)
    at Socket.emit (node:events:511:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

The storybook tests are trying to connect to a real WebSocket server which is not required for storybook tests, so these are ok

knrt10 added a commit that referenced this issue Jan 17, 2025
We now mock console logs in tests and do not console errors for tests
env.

Fixes: #2753
Signed-off-by: Kautilya Tripathi <[email protected]>
knrt10 added a commit that referenced this issue Jan 17, 2025
We now mock console logs in tests and do not console errors for tests
env.

Fixes: #2753
Signed-off-by: Kautilya Tripathi <[email protected]>
knrt10 added a commit that referenced this issue Jan 17, 2025
We now mock console logs in tests and do not console errors for tests
env.

Fixes: #2753
Signed-off-by: Kautilya Tripathi <[email protected]>
knrt10 added a commit that referenced this issue Jan 17, 2025
We now mock console logs in tests and do not console errors for tests
env.

Fixes: #2753
Signed-off-by: Kautilya Tripathi <[email protected]>
knrt10 added a commit that referenced this issue Jan 17, 2025
We now mock console logs in tests and do not console errors for tests
env.

Fixes: #2753
Signed-off-by: Kautilya Tripathi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Issues related to the frontend multi Multi cluster aggregated view
Projects
Development

No branches or pull requests

2 participants