fix: await updatePodfile to prevent race condition during prebuild#254
Open
tarikfp wants to merge 1 commit intoOneSignal:mainfrom
Open
fix: await updatePodfile to prevent race condition during prebuild#254tarikfp wants to merge 1 commit intoOneSignal:mainfrom
tarikfp wants to merge 1 commit intoOneSignal:mainfrom
Conversation
The updatePodfile function was being called without await, causing the Expo prebuild process to continue to pod install before the Podfile was updated with the OneSignalNotificationServiceExtension target. This resulted in build failures with errors like: - 'OneSignalFramework/OneSignalFramework.h' file not found - 'OneSignalExtension/OneSignalExtension.h' file not found Changes: - Add await to updatePodfile call in withOneSignalIos.ts - Use fs.appendFileSync instead of fs.appendFile in updatePodfile.ts
1 task
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.
What's happening
When running
npx expo prebuild, the build randomly fails with:or
The
OneSignalNotificationServiceExtensiontarget never gets added to the Podfile beforepod installruns.Related issues: #231
Why it happens
Two things are causing this:
1. The
updatePodfilecall isn't awaitedIn
withOneSignalIos.ts:The comment says it's intentional, but this causes prebuild to move on to
pod installbefore the Podfile is updated.2. The file write itself is async
In
updatePodfile.ts:Even if we awaited the function,
fs.appendFilewith a callback returns immediately.The fix
withOneSignalIos.tsupdatePodfile.tsTested with
Before/After
Before:
After: