Skip to content

Commit 5214cc0

Browse files
committed
Excluded ngrx, datorama, angular, react and langchain from stream pipe query.
1 parent e964b17 commit 5214cc0

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

javascript/ql/src/Quality/UnhandledStreamPipe.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ API::Node getNonStreamApi() {
4545
exists(string moduleName |
4646
moduleName
4747
.regexpMatch([
48-
"rxjs(|/.*)", "@strapi(|/.*)", "highland(|/.*)", "execa(|/.*)", "arktype(|/.*)"
48+
"rxjs(|/.*)", "@strapi(|/.*)", "highland(|/.*)", "execa(|/.*)", "arktype(|/.*)",
49+
"@ngrx(|/.*)", "@datorama(|/.*)", "@angular(|/.*)", "react.*", "@langchain(|/.*)",
4950
]) and
5051
result = API::moduleImport(moduleName)
5152
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { Suspense } from "react";
2+
import { renderToPipeableStream } from "react-dom/server";
3+
import { PassThrough } from "stream";
4+
import { act } from "react-dom/test-utils";
5+
6+
7+
const writable = new PassThrough();
8+
let output = "";
9+
writable.on("data", chunk => { output += chunk.toString(); });
10+
writable.on("end", () => { /* stream ended */ });
11+
12+
let errors = [];
13+
let shellErrors = [];
14+
15+
await act(async () => {
16+
renderToPipeableStream(
17+
<Suspense fallback={<Fallback />}>
18+
<Throw />
19+
</Suspense>,
20+
{
21+
onError(err) {
22+
errors.push(err.message);
23+
},
24+
onShellError(err) {
25+
shellErrors.push(err.message);
26+
}
27+
}
28+
).pipe(writable);
29+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { RunnablePassthrough, RunnableSequence } from "@langchain/core/runnables";
2+
3+
const fakeRetriever = RunnablePassthrough.from((_q: string) =>
4+
Promise.resolve([{ pageContent: "Hello world." }])
5+
);
6+
7+
const formatDocumentsAsString = (documents: { pageContent: string }[]) =>documents.map((d) => d.pageContent).join("\n\n");
8+
9+
const chain = RunnableSequence.from([
10+
{
11+
context: fakeRetriever.pipe(formatDocumentsAsString),
12+
question: new RunnablePassthrough(),
13+
},
14+
"",
15+
]);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Component } from '@angular/core';
2+
import { Store, select } from '@ngrx/store';
3+
import { Observable } from 'rxjs';
4+
5+
@Component({
6+
selector: 'minimal-example',
7+
template: `
8+
<div>{{ value$ | async }}</div>
9+
`
10+
})
11+
export class MinimalExampleComponent {
12+
value$: Observable<any>;
13+
14+
constructor(private store: Store<any>) {
15+
this.value$ = this.store.pipe(select('someSlice'));
16+
}
17+
}

0 commit comments

Comments
 (0)