Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Some unit tests in grpc-fallback fail silently #182

Closed
googleapis/gax-nodejs
#1766

Description

@leahecole

Some of the tests in grpc-fallback that use proxyquire with node-fetch are failing silently, very similar to this bug mochajs/mocha#4881

tests that have blocks like this

 gaxGrpcMock
      .createStub(echoService, stubOptions)
      .then((echoStub: {echo: any}) => {
        echoStub.echo(requestObject, {}, {}, (err?: Error, result?: {}) => {
          assert.strictEqual(err, null);
          assert.strictEqual(
            requestObject.content,
            (result as {content: string}).content,
          );
        });
      });

Are failing to report an assertion error in the assert.strictEqual(err, null) line.

Update I removed this code snippet because I still didn't quite have it right with callbacks/async etc but I'll work on what needs to change. Might be missing a .then, might need an async/await swap with a try/catch

We should also fix why they're failing (I don't know that part yet) but I want to at least get to a loud failure instead of a silent one 😁

Activity

  1. added
    type: cleanup
    on Apr 23, 2025
  2. leahecole commented on Apr 23, 2025

    @leahecole
    ContributorAuthor

    I think our issue is actually that proxyquire isn't configured properly to proxyquire anything - we have blocks like this

        const {GrpcClient} = await proxyquire('../../src/fallback.js', {
          'node-fetch': () => {
            return Promise.resolve({
              ok: true,
              arrayBuffer: () => {
                return Promise.resolve(Buffer.from(JSON.stringify(response)));
              },
            });
          },
        });
    

    If they are removed, we get the same result -

    err FetchError: request to https://foo.example.com/v1beta1/echo:echo? failed, reason: getaddrinfo ENOTFOUND foo.example.com
        at ClientRequest.<anonymous> (file:///Users/coleleah/workspace/gcp/node/gax-nodejs/gax/node_modules/node-fetch/src/index.js:108:11)
        at ClientRequest.emit (node:events:529:35)
        at TLSSocket.socketErrorListener (node:_http_client:501:9)
        at TLSSocket.emit (node:events:517:28)
        at emitErrorNT (node:internal/streams/destroy:151:8)
        at emitErrorCloseNT (node:internal/streams/destroy:116:3)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
      type: 'system',
      errno: 'ENOTFOUND',
      code: 'ENOTFOUND',
      erroredSysCall: 'getaddrinfo'
    }
    
  3. assigned and unassigned on May 1, 2025
  4. leahecole commented on May 1, 2025

    @leahecole
    ContributorAuthor

    Reassigning to @d-goog because Sofia says he's on it :)

  5. leahecole commented on May 6, 2025

    @leahecole
    ContributorAuthor
  6. leahecole commented on May 27, 2025

    @leahecole
    ContributorAuthor

    Example from Daniel he sent in chat googleapis/gaxios#699

  7. added
    size: m
    on Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

size: mtype: cleanup

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions