Skip to content

Conversation

c-lucera-pvotal
Copy link
Contributor

This PR attempt to solve the issue with headers not being correctly completed after a call is closed as pointed out in #727

To fix the issue I have added in the _terminate() method a check to complete with errors any completer still going (I found _headers and _trailers)

Copy link

linux-foundation-easycla bot commented Aug 8, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@r-durao-pvotal
Copy link

@kevmoo who would be the right person to take a look at this PR? Thanks in advance!

@mraleph
Copy link
Member

mraleph commented Aug 20, 2024

Please add a regression test and then we can land it.

Copy link

github-actions bot commented Aug 20, 2024

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
grpc None 4.0.0 4.0.1 4.0.0 ✔️
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ✔️
File Coverage
lib/src/client/call.dart 💚 85 %

This check for test coverage is informational (issues shown here will not fail the PR).

API leaks ⚠️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
grpc Any
$1.Duration
ServerHandler

This check can be disabled by tagging the PR with skip-leaking-check.

Package publish validation ✔️
Package Version Status
package:grpc 4.0.1 ready to publish

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@c-lucera-pvotal
Copy link
Contributor Author

c-lucera-pvotal commented Aug 20, 2024

@mraleph
Added the requested test and fixed CI issues like Changelog notes.

However I had to change the previous logic from throwing an error

    if (!_headers.isCompleted) {
      _headers.completeError(GrpcError.unimplemented('Request terminated before headers'));
    }

To completing with an empty value

    if (!_headers.isCompleted) {
      _headers.complete({});
    }

The reason about the change was that the error throwing was really distruptive for the current implementations, instead of receving a error only on active listeners (I.e whoever was actively looking at that completer) all the cancelled calls received 3 throws, one for the cancellation, one for the headers not completed and one for the trailers not completed, this meant that all the tests in this project were failing due to the not catched exceptions, and at the same time, anyone cancelling the call had to deal with 3 different throws, I hope this change make sense to you.

@grpc grpc deleted a comment from github-actions bot Aug 20, 2024
@c-lucera-pvotal
Copy link
Contributor Author

@mraleph saw some failing tests, but those seems unrelated to my changes, any hint about those?

@mosuem
Copy link
Contributor

mosuem commented Aug 22, 2024

These keepalive tests can be flaky, but this doesn't look that way. Let me check.

@c-lucera-pvotal
Copy link
Contributor Author

It looks like that the tearDown somehow is not awaiting the closing before the next setUp is running, maybe they are running in parallel?

in line 52 of keep_alive_test.dart, if you use a different port for each serve you will see the tests not failing anymore

//before tests setup
int port = 8081;

//Line 52
 await server.serve(address: 'localhost', port: port++);

Want me to add this?

@c-lucera-pvotal
Copy link
Contributor Author

Another thing I discovered, if I run only keep alive tests it works out of the box, so probably tests are running in parallel with other tests using the port 8081, another fix is to use the port 8282 on line 52

/Line 52
 await server.serve(address: 'localhost', port: 8082);

@c-lucera-pvotal
Copy link
Contributor Author

c-lucera-pvotal commented Aug 22, 2024

Basically those two tests
https://github.com/grpc/grpc-dart/blob/master/test/keepalive_test.dart
https://github.com/grpc/grpc-dart/blob/master/test/server_cancellation_test.dart

uses port 8081, this is not an issue when run one by one, but running the whole suite with flutter test causes he keep_alive failing because the server cancellation test runs first and occupies the port 8081, I can fix this in my pr by changing the port if you want

@c-lucera-pvotal
Copy link
Contributor Author

Pushed the fix for keepalive_test.dart let me know if you prefer to revert it and solve in a different way

@mraleph mraleph merged commit 4f6fe9b into grpc:master Aug 28, 2024
21 checks passed
tsavo-at-pieces added a commit to open-runtime/grpc-dart that referenced this pull request Jan 3, 2025
commit 471a8b3
Author: Tsavo Knott <[email protected]>
Date:   Fri Jan 3 13:02:16 2025 -0500

    Clean Up CI

commit 1632820
Author: Tsavo Knott <[email protected]>
Date:   Fri Jan 3 13:00:20 2025 -0500

    True Upstream Master

commit 1dddfe0
Merge: 774bf81 c9d6286
Author: Tsavo Knott <[email protected]>
Date:   Fri Jan 3 12:32:24 2025 -0500

    Merge pull request #2 from open-runtime/update-from-upstream

    Update from Upstream Master

commit c9d6286
Merge: 774bf81 9a9c017
Author: Tsavo Knott <[email protected]>
Date:   Fri Jan 3 12:31:33 2025 -0500

    Merge branch 'upstream-master' into update-from-upstream

commit 774bf81
Merge: 4a043fa 00eabed
Author: Tsavo Knott <[email protected]>
Date:   Fri Jan 3 12:13:44 2025 -0500

    Merge pull request #1 from open-runtime/aot_monorepo_compat

    Merging AOT Monorepo Compat into our Main Branch

commit 9a9c017
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 17 09:58:22 2024 +0100

    Bump vm_service from 14.3.1 to 15.0.0 (grpc#751)

    Bumps [vm_service](https://github.com/dart-lang/sdk/tree/main/pkg) from 14.3.1 to 15.0.0.
    - [Changelog](https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/dart-lang/sdk/commits/HEAD/pkg)

    ---
    updated-dependencies:
    - dependency-name: vm_service
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Moritz <[email protected]>

commit 3e94fec
Author: Moritz <[email protected]>
Date:   Tue Dec 17 09:53:02 2024 +0100

    Update health.yaml (grpc#753)

    * Update health.yaml

    * Upgrade example

    * Fixes

    * try different syntax

    * without endings

    * test new wf

    * new version

    * Works, use main now

    * Add changelog

commit 6676c20
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Dec 16 13:37:35 2024 +0000

    Bump dart-lang/setup-dart from 1.6.5 to 1.7.0 (grpc#746)

commit f61b9a3
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Nov 4 10:45:05 2024 +0000

    Bump actions/checkout from 4.2.0 to 4.2.2 (grpc#744)

commit c063010
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Oct 1 08:51:16 2024 +0000

    Bump actions/checkout from 4.1.7 to 4.2.0 (grpc#741)

commit 04ba68e
Author: Moritz <[email protected]>
Date:   Tue Oct 1 04:46:38 2024 -0400

    Rev package:lints (grpc#740)

    * Rev package:lints

    * Add changelog

    * Run CI on 3.5.0

    * Test with 3.2.0

    * Update .github/workflows/dart.yml

    Co-authored-by: Kevin Moore <[email protected]>

    * Update .github/workflows/dart.yml

    Co-authored-by: Kevin Moore <[email protected]>

    ---------

    Co-authored-by: Kevin Moore <[email protected]>

commit f8bbdce
Author: Kevin Moore <[email protected]>
Date:   Tue Sep 24 12:07:42 2024 -0700

    ignore unreachable_switch_default in weird switch case (grpc#737)

commit 071ebc5
Author: steffenhaak <[email protected]>
Date:   Fri Sep 6 17:13:11 2024 +0200

    fix: keep alive timeout finishes transport instead of connection shutdown (grpc#722)

    * fix: keep alive timeout finishes transport instead of shutting down channel

    * Update keepalive_test.dart

    * Update CHANGELOG.md

    ---------

    Co-authored-by: Moritz <[email protected]>

commit 8177633
Author: Moritz <[email protected]>
Date:   Fri Sep 6 15:09:54 2024 +0200

    Small fixes (grpc#732)

    * Small fixes

    * Revert changes on file

    * Add changelog

    * Small fixes in keepalive test

    * Add delay

    * Fix symbol visibilty

    * Add try catch for debugging

    * Fail

    * fail

    * Use for loop

commit 38ca626
Author: Lasse R.H. Nielsen <[email protected]>
Date:   Mon Sep 2 16:58:43 2024 +0200

    Use `Map.of` instead of `Map.from` in grpc client. (grpc#724)

    * Use `Map.of` instead of `Map.from` in grpc client.

    `Map.of` creates a new map with the same keys, values and *type*
    as the original map, when used without type arguments or context type,
    where `Map.from` creates a `Map<dynamic, dynamic>`.
    (This code failed on an attempt to make `Map.unmodifiable` be more
    strictly typed, like `Map.of` instead of `Map.from`, showing that
    an intermediate map had type `Map<dynamic, dynamic>` unnecessarily).

    Same for using `List.of` instead of `List.from`.

    The new code should be (microscopically) more efficient and type safe,
    and is forwards-compatible with a stronger type on `Map.unmodifiable`.

    (The code can be optimized more. For example
    `List.of(list1)..addAll(list2)` can be just `list1 + list2` or
    `[...list1, ...list2]`, both of which may know the total number
    of elements when doing the initial list allocation.
    This is a minimal change to allow the type changes for `.unmodifiable`
    to get past this very initial blocker in internal tests.)

    * Add changelog and minor version increment.

    And my save removes trailing spaces.

commit 4f6fe9b
Author: c-lucera-pvotal <[email protected]>
Date:   Wed Aug 28 08:18:15 2024 +0200

    fix: fix headers not completing when call is terminated (grpc#728)

    Fixes grpc#727

commit c18e185
Author: Kevin Moore <[email protected]>
Date:   Wed Jul 24 14:24:57 2024 -0700

    Fix status badge (grpc#726)

commit b999b64
Author: Galen Warren <[email protected]>
Date:   Wed Jul 17 08:11:29 2024 -0400

    feat: fix hang that occurs when hot restarting (grpc#718)

commit bf8bbde
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Jul 1 11:56:47 2024 +0000

    Bump dart-lang/setup-dart from 1.6.4 to 1.6.5 (grpc#720)

commit 4aa4c8c
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Jul 1 11:52:08 2024 +0000

    Bump actions/checkout from 4.1.6 to 4.1.7 (grpc#719)

commit dee1b2b
Author: Kevin Moore <[email protected]>
Date:   Wed May 29 17:23:53 2024 -0700

    Update pubspec.yaml

commit 52023d4
Author: Kevin Moore <[email protected]>
Date:   Tue May 28 14:47:30 2024 -0700

    code fixes

commit ebb7368
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed May 22 06:56:00 2024 +0000

    Bump lints from 3.0.0 to 4.0.0

    Bumps [lints](https://github.com/dart-lang/lints) from 3.0.0 to 4.0.0.
    - [Release notes](https://github.com/dart-lang/lints/releases)
    - [Changelog](https://github.com/dart-lang/lints/blob/main/CHANGELOG.md)
    - [Commits](dart-archive/lints@v3.0.0...v4.0.0)

    ---
    updated-dependencies:
    - dependency-name: lints
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit 4e65d4b
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue May 21 11:05:38 2024 +0000

    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit 1495453
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue May 21 11:01:10 2024 +0000

    Bump dart-lang/setup-dart from 1.6.2 to 1.6.4

    Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.2 to 1.6.4.
    - [Release notes](https://github.com/dart-lang/setup-dart/releases)
    - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md)
    - [Commits](dart-lang/setup-dart@fedb126...f0ead98)

    ---
    updated-dependencies:
    - dependency-name: dart-lang/setup-dart
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit 6586b74
Author: Sarah Zakarias <[email protected]>
Date:   Tue May 21 12:30:20 2024 +0200

    Add `topics` to `pubspec.yaml` (grpc#712)

commit 9f65399
Author: Moritz <[email protected]>
Date:   Fri May 17 14:53:33 2024 +0200

    Move `codec.dart` to former place (grpc#713)

commit 0d02e43
Author: Moritz <[email protected]>
Date:   Mon May 6 06:25:06 2024 -0700

    Remove dependency on `package:archive` (grpc#707)

    * Remove dependency on package:archive

    * Test compression on vm only

    * Add licenses

    * Fix analyze issues

    * Fix codec web

    * Fix licenses

    * Add changelog

commit 078fd23
Author: Moritz <[email protected]>
Date:   Thu Apr 25 04:45:40 2024 -0700

    Remove generated `StatusCode` (grpc#703)

    * Remove generated `StatusCode`

    * Rev version for breaking change

    * Upgrade min sdk version

    * Fix issues

commit bdbe5f5
Author: Ruben Garcia <[email protected]>
Date:   Mon Apr 22 16:09:18 2024 +0200

    Fix issue 669 (grpc#693)

    * Fix issue 669

    * Update CHANGELOG.md

    * Update CHANGELOG.md

    * Fix dart format issue.
    Fix prefer single quote issue.

    * Update pubspec and changelog to avoid merge check
    publish / validate
    validate packages

    * Add test for GRPC Compression Flag

    * Fix dart analyze issues.

    * Fix latest dart analyze issue (uninizialized variable)

commit bb8b6e5
Author: Moritz <[email protected]>
Date:   Fri Apr 19 02:05:59 2024 -0700

    Make protobuf generated imports absolute (grpc#696)

    * Make protobuf generated imports absolute

    * Stop test for now

commit b05fafe
Author: Moritz <[email protected]>
Date:   Mon Apr 15 04:43:26 2024 -0700

    Add Health workflow (grpc#699)

    * Add Health workflow

    * Remove license check

commit aece2a4
Author: Abdul Momin <[email protected]>
Date:   Mon Apr 15 12:53:00 2024 +0500

    Typo Correction in README.md (grpc#695)

    Corrected typo "RPs" to "RPCs". To avoid confusion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants