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

UnhandledPromiseRejection when running cp.cpToPod with wrong namespace/pod name #1235

Closed
pauloamed opened this issue Aug 30, 2023 · 1 comment

Comments

@pauloamed
Copy link

Describe the bug
Getting the following uncaght error when running cp.cpToPod with a wrong namespace or pod name.

Uncaught Error UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<ErrorEvent>".

Traces down to connect(path, textHandler, binaryHandler) in WebSocketHandler, returning a 404 when trying to connect to the cluster+namespace+pod.

Client Version
0.18.1

Server Version
1.26.7

To Reproduce
Just run the following code using a wrong namespace or pod name

Expected behavior
Correct error handling by the cpToPod method.

Example Code

import * as k8s from '@kubernetes/client-node';

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const cp = new k8s.Cp(kc);


const main = async () => {
    try{
        await cp.cpToPod(NAMESPACE, , WRONG_POD_NAME, './test.txt', '/tmp');
    }catch(err) {
        console.log(err)
    }
};

main();

Environment (please complete the following information):

  • OS: Ubuntu 22.04.2 LTS
  • NodeJS Version: v16.19.0
  • Cloud runtime: GKE

Additional context
I guess that the main problem is that there isn't an await here
https://github.com/kubernetes-client/javascript/blob/6a8337ff8a97eba7bc143f87303754e4f488eb15/src/cp.ts#L81C6-L81C6

@pauloamed
Copy link
Author

Just saw #988, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant