Skip to content

Conversation

@dynst
Copy link
Contributor

@dynst dynst commented Jul 23, 2025

One-third of #1724. Closes #1724

Looks like this test code was inherited from #246

https://github.com/webpack/webpack/releases/v5.92.0

webpack added a feature that adds node: prefixes "in runtime code," but still compile-time rejects it if it's already present in the code, and the target is a browser. Even if it's a dynamic import, which can fail.

@dynst dynst force-pushed the socket-test branch 2 times, most recently from 31d4f08 to 6f2b6e3 Compare July 23, 2025 02:54
Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Nice. Could you update to latest main and remove the dependency changes from the PR? Then we can get this in and close #1724 – great stuff

const ret = new Promise<void>((resolve, reject) => {
pass = resolve;
fail = reject;
});
Copy link
Member

Choose a reason for hiding this comment

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

I think it is a bit less boilerplate and more natural to use (done) => with an inner unnamed async function. See e.g.

it("can subscribe to block header events", (done) => {
    pendingWithoutTendermint();

    const testStart = ReadonlyDate.now();

    (async () => {
      const events: responses.NewBlockHeaderEvent[] = [];
      const client = Tendermint37Client.create(rpcFactory());
      const stream = client.subscribeNewBlockHeader();
      expect(stream).toBeTruthy();
      // ...

in this codebase

Copy link
Contributor Author

@dynst dynst Jul 23, 2025

Choose a reason for hiding this comment

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

Wait, how would that even work?

And ideally all this code would be refactored to be Promise-y instead of callback-y to avoid this boilerplate kludge that combines the 2 styles, do you not think this is a step in the right direction and a reminder to more fully rewrite the test later?

Copy link
Member

Choose a reason for hiding this comment

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

No super strong opinion. I was just remembering that we had those cases before and here it looks like a lot of boilerplate. But at the end of the day I am happy either way

Copy link
Member

Choose a reason for hiding this comment

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

@webmaster128 webmaster128 changed the title update socket test Modernize child_process import in reconnecting socket test Jul 24, 2025
@webmaster128 webmaster128 merged commit 960368c into cosmos:main Jul 24, 2025
16 checks passed
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

Successfully merging this pull request may close these issues.

removing require() calls

2 participants