PapaParse icon indicating copy to clipboard operation
PapaParse copied to clipboard

Complete callback does not fire when Step and Preview used together

Open riiiiizzzzzohmmmmm opened this issue 8 years ago • 7 comments

So, I don't think this actually a bug, just potentially confusing, although I was ultimately able to make sense out of it:

If you pass both preview and step options and your data source has more than preview rows, then the complete callback never fires. Although, it just so happens that if your data source has the same number of rows as preview, then the complete callback fires even if you have also defined a step callback. I haven't tested if complete also fires in these circumstances if the data source as fewer than preview rows, but you get the picture.

Again, not exactly a bug, but I wanted to drop a note here.

riiiiizzzzzohmmmmm avatar Oct 28 '16 14:10 riiiiizzzzzohmmmmm

it also doesn't fire when chunk is used and file size is less than chunk size. (meaning chunk is only called once for file)

r3wt avatar Feb 10 '17 19:02 r3wt

Can confirm that complete does fire when the amount of lines is less than the preview specified, but not when the amount of lines is longer than preview

Again, not exactly a bug

Would definitely consider this a bug.

davidlumley avatar Jun 23 '17 21:06 davidlumley

It's not a bug, because the intention was that complete only fires when the full input has been read, which preview prevents from happening if the input is longer. However, the docs aren't clear because they say "when parsing is complete" -- we should either clarify the docs or change the behavior to call complete when the preview (if any) is also done parsing.

mholt avatar Jun 24 '17 01:06 mholt

This also happens when using in Node with the Papa.NODE_STREAM_INPUT to parse a stream with the preview configuration option. Spent a few hours trying to figure out what I did wrong before I realized that the Papa.parse stream never fires the end event if the preview rows are all received before the source stream is completely processed.

If avoiding changes to the current behavior is important it may work to either add a new event (maybe finish or done or something like that) to indicate that Papa.parse is doing no further parsing, or perhaps to fire an end event when the underlying stream that is being piped to Papa.parse fires its own end event.

fomojola avatar May 09 '19 03:05 fomojola

Any update on this? This I agree is an important feature - having a callback even if preview is true. The last post I thought would be a great compromise to all of the solutions mentioned here.

tfrancois avatar Nov 10 '21 21:11 tfrancois

Any update on this?

tfrancois avatar Aug 18 '22 06:08 tfrancois

I'd be interested in a clean solution for this one.

FooF0x avatar Oct 19 '22 03:10 FooF0x