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

@types/k6 Fix runtime error when grcp Stream experimental #13

Closed
wants to merge 1 commit into from

Conversation

jyeros
Copy link

@jyeros jyeros commented Jul 14, 2023

If try to run a k6 script with the steam event types like:

import grpc from "k6/experimental/grpc";

const stream = new grpc.Stream(...);

stream.on(grpc.StreamEvent.Data, (d) => {
  console.log(JSON.stringify(d));
});

I am getting a runtime error ERRO[0000] TypeError: Cannot read property 'Data' of undefined. It looks like the StreamEvent enum is not defined. But, it works if we run it like:

import grpc from "k6/experimental/grpc";

const stream = new grpc.Stream(...);

-stream.on(grpc.StreamEvent.Data, (d) => {
+stream.on('data', (d) => {
  console.log(JSON.stringify(d));
});

So, changing StreamEvent from enum to union of string literal types works in runtime and enforce types.

@CLAassistant
Copy link

CLAassistant commented Jul 14, 2023

CLA assistant check
All committers have signed the CLA.

@olegbespalov olegbespalov changed the base branch from master to version/0.46 August 10, 2023 14:22
@olegbespalov
Copy link

Hi @jyeros !

Changes look good 👍

One thing could you please point them directly to the upstream (https://github.com/DefinitelyTyped/DefinitelyTyped/)?

@jyeros
Copy link
Author

jyeros commented Aug 10, 2023

DefinitelyTyped#66340, I am not sure if you want me to do version bump

@jyeros
Copy link
Author

jyeros commented Aug 14, 2023

Merged on base repo DefinitelyTyped#66340

@jyeros jyeros closed this Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants