Git Product home page Git Product logo

Comments (6)

mscdex avatar mscdex commented on August 22, 2024

I'm not sure what you're saying. file is just a normal node Readable stream (aside from the custom limit-related event and property), so all of the normal node stream behaviors apply. If you're seeing 'data' events after 'end'/'close' events, then that's a node.js bug.

from busboy.

Hyodori04 avatar Hyodori04 commented on August 22, 2024

I mean when reading multiple files. Before first files occur 'end' events, event "data" of secods file occurs. This order is not handled by busboy?

from busboy.

mscdex avatar mscdex commented on August 22, 2024

I would say that would be due to node delaying 'end'/'close' events until at least the next tick of the event loop and/or #346.

from busboy.

Hyodori04 avatar Hyodori04 commented on August 22, 2024

Thanks for fast anwser. I will find some way to solve this issue.

from busboy.

Hyodori04 avatar Hyodori04 commented on August 22, 2024

I think this timing issue not happens randomly. It's related files size. (If it's related only even loop, I think it should happens randomly) Only certain size of file group generate this problem. Is there any way to handle this issue in busboy?

from busboy.

Hyodori04 avatar Hyodori04 commented on August 22, 2024

I have solved this issue by using pause and resume function in readalbe objects

    let index = 0;
    const fileList: Readable[] = [];

    BusBoy.on("file", (fieldName: string, file: Readable, info: FileInfo) => {
      let isFirst = true;
      const ownerIndex = index;
      index += 1;

      file.pause();
      fileList.push(file);

      const isFirstFile = ownerIndex === 0;

      if (isFirstFile) {
        const targetFile = fileList.shift();
        targetFile!.resume();
      }

      file.on("data", (chunk: Buffer) => {
         // implementation
      });

      file.on("end", () => {
         // implementation

        const nextFile = fileList.shift();
        if (nextFile) {
          nextFile.resume();
          return;
        }
      });
    });

from busboy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.