Merge branch 'main' into js-clientrests-axios

This commit is contained in:
Mathew Payne
2025-06-09 14:18:54 +01:00
committed by GitHub
742 changed files with 14263 additions and 9051 deletions

View File

@@ -0,0 +1,19 @@
| test.js:4:5:4:28 | stream. ... nation) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:19:5:19:17 | s2.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:45:5:45:30 | stream2 ... ation2) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:60:5:60:30 | stream2 ... ation2) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:66:5:66:21 | stream.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:79:5:79:25 | s2.pipe ... ation2) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:94:5:94:21 | stream.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:110:11:110:22 | s.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:119:5:119:21 | stream.pipe(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:128:5:128:26 | getStre ... e(dest) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:146:5:146:62 | stream. ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:182:17:182:40 | notStre ... itable) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| test.js:192:5:192:32 | copyStr ... nation) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| tst.js:8:5:8:21 | source.pipe(gzip) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| tst.js:37:21:37:56 | wrapper ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| tst.js:44:5:44:40 | wrapper ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| tst.js:52:5:52:37 | source. ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| tst.js:59:18:59:39 | stream. ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |
| tst.js:111:5:111:26 | stream. ... Stream) | Stream pipe without error handling on the source stream. Errors won't propagate downstream and may be silently dropped. |

View File

@@ -0,0 +1,2 @@
query: Quality/UnhandledErrorInStreamPipeline.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -0,0 +1,3 @@
import { type } from 'arktype';
type.string.pipe(Number);

View File

@@ -0,0 +1,11 @@
const execa = require('execa');
(async () => {
const first = execa('node', ['empty.js']);
const second = execa('node', ['stdin.js']);
first.stdout.pipe(second.stdin);
const {stdout} = await second;
console.log(stdout);
})();

View File

@@ -0,0 +1,29 @@
import React, { Suspense } from "react";
import { renderToPipeableStream } from "react-dom/server";
import { PassThrough } from "stream";
import { act } from "react-dom/test-utils";
const writable = new PassThrough();
let output = "";
writable.on("data", chunk => { output += chunk.toString(); });
writable.on("end", () => { /* stream ended */ });
let errors = [];
let shellErrors = [];
await act(async () => {
renderToPipeableStream(
<Suspense fallback={<Fallback />}>
<Throw />
</Suspense>,
{
onError(err) {
errors.push(err.message);
},
onShellError(err) {
shellErrors.push(err.message);
}
}
).pipe(writable);
});

View File

@@ -0,0 +1,8 @@
const highland = require('highland');
const fs = require('fs');
highland(fs.createReadStream('input.txt'))
.map(line => {
if (line.length === 0) throw new Error('Empty line');
return line;
}).pipe(fs.createWriteStream('output.txt'));

View File

@@ -0,0 +1,15 @@
import { RunnablePassthrough, RunnableSequence } from "@langchain/core/runnables";
const fakeRetriever = RunnablePassthrough.from((_q: string) =>
Promise.resolve([{ pageContent: "Hello world." }])
);
const formatDocumentsAsString = (documents: { pageContent: string }[]) =>documents.map((d) => d.pageContent).join("\n\n");
const chain = RunnableSequence.from([
{
context: fakeRetriever.pipe(formatDocumentsAsString),
question: new RunnablePassthrough(),
},
"",
]);

View File

@@ -0,0 +1,17 @@
import { Component } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs';
@Component({
selector: 'minimal-example',
template: `
<div>{{ value$ | async }}</div>
`
})
export class MinimalExampleComponent {
value$: Observable<any>;
constructor(private store: Store<any>) {
this.value$ = this.store.pipe(select('someSlice'));
}
}

View File

@@ -0,0 +1,20 @@
import * as rx from 'rxjs';
import * as ops from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { pluck } from "rxjs/operators/pluck";
const { of, from } = rx;
const { map, filter } = ops;
function f(){
of(1, 2, 3).pipe(map(x => x * 2));
someNonStream().pipe(map(x => x * 2));
let testScheduler = new TestScheduler();
testScheduler.run(({x, y, z}) => {
const source = x('', {o: [a, b, c]});
z(source.pipe(null)).toBe(expected,y,);
});
z.option$.pipe(pluck("x"))
}

View File

@@ -0,0 +1,5 @@
import { async } from '@strapi/utils';
const f = async () => {
const permissionsInDB = await async.pipe(strapi.db.query('x').findMany,map('y'))();
}

View File

@@ -0,0 +1,235 @@
function test() {
{
const stream = getStream();
stream.pipe(destination).on("error", e); // $Alert
}
{
const stream = getStream();
stream.pipe(destination);
stream.on('error', handleError);
}
{
const stream = getStream();
stream.on('error', handleError);
stream.pipe(destination);
}
{
const stream = getStream();
const s2 = stream;
s2.pipe(dest).on("error", e); // $Alert
}
{
const stream = getStream();
stream.on('error', handleError);
const s2 = stream;
s2.pipe(dest);
}
{
const stream = getStream();
const s2 = stream;
s2.on('error', handleError);
s2.pipe(dest);
}
{
const s = getStream().on('error', handler);
const d = getDest();
s.pipe(d);
}
{
getStream().on('error', handler).pipe(dest);
}
{
const stream = getStream();
stream.on('error', handleError);
const stream2 = stream.pipe(destination);
stream2.pipe(destination2).on("error", e); // $Alert
}
{
const stream = getStream();
stream.on('error', handleError);
const destination = getDest();
destination.on('error', handleError);
const stream2 = stream.pipe(destination);
const s3 = stream2;
s = s3.pipe(destination2);
}
{
const stream = getStream();
stream.on('error', handleError);
const stream2 = stream.pipe(destination);
stream2.pipe(destination2).on("error", e); // $Alert
}
{ // Error handler on destination instead of source
const stream = getStream();
const dest = getDest();
dest.on('error', handler);
stream.pipe(dest).on("error", e); // $Alert
}
{ // Multiple aliases, error handler on one
const stream = getStream();
const alias1 = stream;
const alias2 = alias1;
alias2.on('error', handleError);
alias1.pipe(dest);
}
{ // Multiple pipes, handler after first pipe
const stream = getStream();
const s2 = stream.pipe(destination1);
stream.on('error', handleError);
s2.pipe(destination2).on("error", e); // $Alert
}
{ // Handler registered via .once
const stream = getStream();
stream.once('error', handleError);
stream.pipe(dest);
}
{ // Handler registered with arrow function
const stream = getStream();
stream.on('error', (err) => handleError(err));
stream.pipe(dest);
}
{ // Handler registered for unrelated event
const stream = getStream();
stream.on('close', handleClose);
stream.pipe(dest).on("error", e); // $Alert
}
{ // Error handler registered after pipe, but before error
const stream = getStream();
stream.pipe(dest);
setTimeout(() => stream.on('error', handleError), 8000); // $MISSING:Alert
}
{ // Pipe in a function, error handler outside
const stream = getStream();
function doPipe(s) { s.pipe(dest); }
stream.on('error', handleError);
doPipe(stream);
}
{ // Pipe in a function, error handler not set
const stream = getStream();
function doPipe(s) {
f = s.pipe(dest); // $Alert
f.on("error", e);
}
doPipe(stream);
}
{ // Dynamic event assignment
const stream = getStream();
const event = 'error';
stream.on(event, handleError);
stream.pipe(dest).on("error", e); // $SPURIOUS:Alert
}
{ // Handler assigned via variable property
const stream = getStream();
const handler = handleError;
stream.on('error', handler);
stream.pipe(dest);
}
{ // Pipe with no intermediate variable, no error handler
getStream().pipe(dest).on("error", e); // $Alert
}
{ // Handler set via .addListener synonym
const stream = getStream();
stream.addListener('error', handleError);
stream.pipe(dest).on("error", e);
}
{ // Handler set via .once after .pipe
const stream = getStream();
stream.pipe(dest);
stream.once('error', handleError);
}
{ // Long chained pipe with error handler
const stream = getStream();
stream.pause().on('error', handleError).setEncoding('utf8').resume().pipe(writable);
}
{ // Long chained pipe without error handler
const stream = getStream();
stream.pause().setEncoding('utf8').resume().pipe(writable).on("error", e); // $Alert
}
{ // Long chained pipe without error handler
const stream = getStream();
stream.pause().setEncoding('utf8').on("error", e).resume().pipe(writable).on("error", e);
}
{ // Non-stream with pipe method that returns subscribable object (Streams do not have subscribe method)
const notStream = getNotAStream();
notStream.pipe(writable).subscribe();
}
{ // Non-stream with pipe method that returns subscribable object (Streams do not have subscribe method)
const notStream = getNotAStream();
const result = notStream.pipe(writable);
const dealWithResult = (result) => { result.subscribe(); };
dealWithResult(result);
}
{ // Non-stream with pipe method that returns subscribable object (Streams do not have subscribe method)
const notStream = getNotAStream();
const pipeIt = (someVariable) => { return someVariable.pipe(something); };
let x = pipeIt(notStream);
x.subscribe();
}
{ // Calling custom pipe method with no arguments
const notStream = getNotAStream();
notStream.pipe();
}
{ // Calling custom pipe method with more then 2 arguments
const notStream = getNotAStream();
notStream.pipe(arg1, arg2, arg3);
}
{ // Member access on a non-stream after pipe
const notStream = getNotAStream();
const val = notStream.pipe(writable).someMember;
}
{ // Member access on a stream after pipe
const notStream = getNotAStream();
const val = notStream.pipe(writable).on("error", e).readable; // $Alert
}
{ // Method access on a non-stream after pipe
const notStream = getNotAStream();
const val = notStream.pipe(writable).someMethod();
}
{ // Pipe on fs readStream
const fs = require('fs');
const stream = fs.createReadStream('file.txt');
const copyStream = stream;
copyStream.pipe(destination).on("error", e); // $Alert
}
{
const notStream = getNotAStream();
const something = notStream.someNotStreamPropertyAccess;
const val = notStream.pipe(writable);
}
{
const notStream = getNotAStream();
const something = notStream.someNotStreamPropertyAccess();
const val = notStream.pipe(writable);
}
{
const notStream = getNotAStream();
notStream.pipe({});
}
{
const notStream = getNotAStream();
notStream.pipe(()=>{});
}
{
const plumber = require('gulp-plumber');
getStream().pipe(plumber()).pipe(dest).pipe(dest).pipe(dest);
}
{
const plumber = require('gulp-plumber');
const p = plumber();
getStream().pipe(p).pipe(dest).pipe(dest).pipe(dest);
}
{
const plumber = require('gulp-plumber');
const p = plumber();
getStream().pipe(p);
}
{
const plumber = require('gulp-plumber');
const p = plumber();
getStream().pipe(p).pipe(dest);
}
{
const notStream = getNotAStream();
notStream.pipe(getStream(),()=>{});
}
}

View File

@@ -0,0 +1,113 @@
const fs = require('fs');
const zlib = require('zlib');
function foo(){
const source = fs.createReadStream('input.txt');
const gzip = zlib.createGzip();
const destination = fs.createWriteStream('output.txt.gz');
source.pipe(gzip).pipe(destination); // $Alert
gzip.on('error', e);
}
class StreamWrapper {
constructor() {
this.outputStream = getStream();
}
}
function zip() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper();
let stream = wrapper.outputStream;
stream.on('error', e);
stream.pipe(zipStream);
zipStream.on('error', e);
}
function zip1() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper();
wrapper.outputStream.pipe(zipStream);
wrapper.outputStream.on('error', e);
zipStream.on('error', e);
}
function zip2() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper();
let outStream = wrapper.outputStream.pipe(zipStream); // $Alert
outStream.on('error', e);
}
function zip3() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper();
wrapper.outputStream.pipe(zipStream); // $Alert
zipStream.on('error', e);
}
function zip3() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper();
let source = getStream();
source.pipe(wrapper.outputStream); // $Alert
wrapper.outputStream.on('error', e);
}
function zip4() {
const zipStream = createWriteStream(zipPath);
let stream = getStream();
let output = stream.pipe(zipStream); // $Alert
output.on('error', e);
}
class StreamWrapper2 {
constructor() {
this.outputStream = getStream();
this.outputStream.on('error', e);
}
}
function zip5() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper2();
wrapper.outputStream.pipe(zipStream);
zipStream.on('error', e);
}
class StreamWrapper3 {
constructor() {
this.stream = getStream();
}
pipeIt(dest) {
return this.stream.pipe(dest);
}
register_error_handler(listener) {
return this.stream.on('error', listener);
}
}
function zip5() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper3();
wrapper.pipeIt(zipStream); // $MISSING:Alert
zipStream.on('error', e);
}
function zip6() {
const zipStream = createWriteStream(zipPath);
let wrapper = new StreamWrapper3();
wrapper.pipeIt(zipStream);
wrapper.register_error_handler(e);
zipStream.on('error', e);
}
function registerErr(stream, listerner) {
stream.on('error', listerner);
}
function zip7() {
const zipStream = createWriteStream(zipPath);
let stream = getStream();
registerErr(stream, e);
stream.pipe(zipStream); // $SPURIOUS:Alert
zipStream.on('error', e);
}