Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Fix data parameter always undefined on callback for track method #231

Merged
merged 5 commits into from
Feb 17, 2021

Conversation

albertininm
Copy link
Contributor

Fixes: #230

@albertininm albertininm requested a review from f2prateek January 23, 2020 13:41
@f2prateek f2prateek removed their request for review February 18, 2020 22:09
Copy link
Contributor

@danieljackins danieljackins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to only add the callback to that flush call and not the other two?

@albertininm
Copy link
Contributor Author

@danieljackins I didn't need to change anywhere else since the place I added solved my problem. Feel free to add in the other places.

@albertininm
Copy link
Contributor Author

@danieljackins just added the callback parameter to the this.flush call as you asked. Could you please review this PR again?
There are other people facing the same problem.
Check #230

Copy link
Contributor

@pbassut pbassut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind make that little change? Just so we're consistent on all three callback

return
}

if (this.queue.length >= this.flushAt) {
this.flush()
this.flush(callback)
}

if (this.flushInterval && !this.timer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also another one here:

this.timer = setTimeout(this.flush.bind(this), this.flushInterval)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, @pbassut
just applied the suggestion!

@pooyaj pooyaj merged commit fbbc5ec into segmentio:master Feb 17, 2021
return
}

if (this.queue.length >= this.flushAt) {
this.flush()
this.flush(callback)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird bug, may not cause issues, but this actually causes the callback to be called twice now as its the exact same callback pulled from the item when flushed.
https://github.com/segmentio/analytics-node/blob/master/index.js#L247-L259

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc - @pbassut

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the callback is running twice for me as well. Is there a plan to fix that? Or should I log a new issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a fix ASAP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Was the fix for this released with v5.1.0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pooyaj It's fixed locally. I'm writing some tests and I'll create a PR for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrandonNoad Can you give me a minimal working example that illustrates the issue?

For issue #1: seems unlikely given they're only called when the request to segment servers actually finishes(successfully or not).

As for issue #2: I'll have to see some code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrandonNoad Please open a new issue for it though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pbassut Yes, I can open a new issue with some code to reproduce the behaviour.

For issue #1: seems unlikely given they're only called when the request to segment servers actually finishes(successfully or not).

I may have been incorrect in saying "too early". That was just an assumption based on the fact that the callback is being called twice and in the first call, batch is undefined.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New issue is here: #300

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data parameter does not return any data when calling .track method
7 participants