Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
Conversion 'GridFSBucketWriteStream' to type 'WritableStream' impossible?

Recently the conversion of GridFSBucketWriteStream to type WritableStream became impossible and leads to a types error.

const wst = svcMng.DBService.projectImageGrid.openUploadStream(image.name);
const uploadPromise = new Promise((resolve, reject) => {
    const read = new Readable({
        read() {
            this.push(image.data);
            this.push(null);
        }
    });

    read.on('error', (err) => {
        reject(err);
    });
    read.on('end', () => {
        resolve(null);
    });
    read.pipe(wst);
});
await uploadPromise;

read.pipe(wst) leads to: Argument of type 'GridFSBucketWriteStream' is not assignable to parameter of type 'WritableStream'.

wst is a GridFSBucketWriteStream type and should be convertible to WritableStream as GridFSBucketWriteStream class implements NodeJS.WritableStream.

Of course read.pipe(wst as any) solve the issue but I would like to avoid it.

read.pipe(wst as NodeJS.WritableStream) is not working also.

Versions:

  • mongoose: 6.1.4
  • typescript: 4.1.2
  • node v12.16.3

Thank you in advance for the help !

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

UPDATE: This issue has since been resolved (about 6 hours after my answer below) with mongodb version 4.3.0. (Here was the bug report: jira.mongodb.org/browse/NODE-3843)

I ran into the same problem and found a workaround. It was implicitly installing @types/node version 17.0.8 (See @types/node/package.json in node_modules). The breaking change is between Node 16 and Node 17 in the WritableStream interface. The end method used to return void and now returns this.

You can specify the version of Node types you want by running:

npm install --save-dev @types/node@16

It seems in the long term, the mongodb Node driver project needs to fix its compatibility with Node 17. But this workaround helped me for now.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda