Skip to content

Commit 1a0d9bd

Browse files
committed
Merge remote-tracking branch 'origin/v2.5' into master
2 parents 4e1dfcb + 6289cb4 commit 1a0d9bd

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

src/Nerdbank.Streams/Nerdbank.Streams.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" PrivateAssets="compile" />
22+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" />
2323
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.0" PrivateAssets="all" />
2424
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="16.7.56" PrivateAssets="build;analyzers;compile" />
2525
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.7.56" PrivateAssets="all" />

src/nerdbank-streams/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
dist/
2-
*.js
2+
out/
3+
asyncprocess.js
4+
gulpfile.js
35
*.d.ts
46
*.js.map

src/nerdbank-streams/gulpfile.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ async function copyPackageContents() {
1717
.src([
1818
"package.json",
1919
"README.md",
20-
"out/*",
2120
])
2221
.pipe(gulp.dest(outDir));
22+
await gulp
23+
.src(["out/*"])
24+
.pipe(gulp.dest(path.join(outDir, 'js')));
25+
await gulp
26+
.src(["src/*"])
27+
.pipe(gulp.dest(path.join(outDir, 'src')));
2328
}
2429

2530
async function setPackageVersion() {

src/nerdbank-streams/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"multiplexing",
99
"duplex"
1010
],
11-
"main": "index.js",
11+
"main": "js/index.js",
1212
"homepage": "https://github.com/AArnott/Nerdbank.Streams",
1313
"repository": {
1414
"type": "git",

src/nerdbank-streams/src/Channel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { MultiplexingStreamClass, MultiplexingStream } from "./MultiplexingStrea
99
import { OfferParameters } from "./OfferParameters";
1010
import { AcceptanceParameters } from "./AcceptanceParameters";
1111
import { QualifiedChannelId, ChannelSource } from "./QualifiedChannelId";
12+
import caught = require("caught");
1213

1314
export abstract class Channel implements IDisposableObservable {
1415
/**
@@ -197,6 +198,11 @@ export class ChannelClass extends Channel {
197198
const cancellationReason = new CancellationToken.CancellationError(reason);
198199
this._acceptance.reject(cancellationReason);
199200
this._completion.reject(cancellationReason);
201+
202+
// Also mark completion's promise rejections as 'caught' since we do not require
203+
// or even expect it to be recognized by anyone else.
204+
// The acceptance promise rejection is observed by the offer channel method.
205+
caught(this._completion.promise);
200206
}
201207

202208
public onAccepted(acceptanceParameter: AcceptanceParameters): boolean {

src/nerdbank-streams/src/tests/MultiplexingStream.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { getBufferFrom } from "../Utilities";
66
import { startJsonRpc } from "./jsonRpcStreams";
77
import { timeout } from "./Timeout";
88
import { Channel } from "../Channel";
9+
import CancellationToken from "cancellationtoken";
10+
import * as assert from "assert";
911

1012
[1, 2, 3].forEach(protocolMajorVersion => {
1113
describe(`MultiplexingStream v${protocolMajorVersion}`, () => {
@@ -105,7 +107,14 @@ import { Channel } from "../Channel";
105107
await expectThrow(offer.acceptance);
106108
});
107109

108-
it("Channel offer is canceled by event handler", async () => {
110+
it("Channel offer is canceled by sender", async () => {
111+
const cts = CancellationToken.create();
112+
const offer = mx1.offerChannelAsync('', undefined, cts.token);
113+
cts.cancel();
114+
await assert.rejects(offer);
115+
});
116+
117+
it("Channel offer is rejected by event handler", async () => {
109118
const handler = new Deferred<void>();
110119
mx2.on("channelOffered", (args) => {
111120
try {

0 commit comments

Comments
 (0)