fix(node): identifyImmediate does not await its network request#3640
Merged
Conversation
The `identifyImmediate` promise was resolving before the underlying `identifyStatelessImmediate` call completed, because the super call was neither awaited nor returned. In short-lived runtimes (Vercel, Cloudflare Workers, Convex actions) the process tears down right after the await, so the `$identify` event was silently dropped. Same class of bug as #2225 (captureImmediate) and #3238 (captureExceptionImmediate). The `@posthog/convex` component already worked around this by routing `$identify` through `captureImmediate` — the workaround comment in packages/convex/src/component/lib.ts points at the exact line being fixed here. Generated-By: PostHog Code Task-Id: 26e22462-2ee6-4ffa-9c33-1f68fd2ed2b1
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Reviews (1): Last reviewed commit: "fix(node): identifyImmediate does not aw..." | Re-trigger Greptile |
Contributor
Contributor
|
Size Change: -4.46 kB (-0.03%) Total Size: 16 MB
ℹ️ View Unchanged
|
marandaneto
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostHogBackendClient.identifyImmediateis documented as the synchronous variant ofidentify— callersawaitthe returned promise to make sure the$identifyevent is on the wire before short-lived runtimes (Vercel, Cloudflare Workers, Convex actions) tear down.Today it is missing an
await(orreturn) on the underlyingsuper.identifyStatelessImmediate(...)call:so the returned promise resolves before the network request completes, and
$identifyevents are silently dropped in serverless contexts.Related to #3238
This was found by following up on the suggestion in #3238 — that PR fixed the same class of bug for
captureExceptionImmediateand explicitly recommended a scan of the other*Immediatemethods for the same shape. This PR is that scan: of the four*Immediatemethods onPostHogBackendClient,identifyImmediateis the remaining one that drops its inner promise. (captureImmediatewas fixed in #2225,aliasImmediatealreadyawaits correctly,captureExceptionImmediateis #3238.)The
@posthog/convexpackage already documents the workaround for this exact bug inpackages/convex/src/component/lib.ts, routing$identifythroughcaptureImmediateinstead.Refs #3238
Changes
Also added a regression test that asserts the batch endpoint has been hit by the time
await posthog.identifyImmediate(...)resolves. The convex workaround comment is left in place — removing it is a separate change for the@posthog/convexpackage with its own release implications, and the workaround keeps working after this fix.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset fileCreated with PostHog Code