create-strapi-app doesn't await writing license.txt, so a failed write skips its error handling
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- playwright, typescript
Research direction
Start with the growth SSO trial block in packages/cli/create-strapi-app/src/create-strapi.ts, around lines 176-186, and add await to the fse.writeFile call for license.txt. Then check the four unawaited calls in tests/e2e/tests: clickLoginTimes in admin/login.spec.ts, previousVersion.click in content-manager/history.spec.ts, and titleBox.fill in content-manager/preview.spec.ts. Done when every one of these promises is awaited and the affected create-strapi-app and e2e tests still pass.
Written by the indexing model from the issue text.
Description
Node Version
Any (found in the code)
Package Manager
Any
Package Manager Version
Any
Strapi Version
develop at 6ed1be0
Operating System
Any
Database
Any
Javascript or Typescript
TypeScript
Bug Description
In create-strapi.ts, the growth SSO trial license is written without await:
try {
const data = await createGrowthSsoTrial({ strapiVersion: scope.strapiVersion });
if (data?.license) {
fse.writeFile(join(rootPath, 'license.txt'), data.license);
logger.log('Your 30 days trial will be applied automatically to your project. Enjoy!');
}
} catch {
logger.error('Error while trying to create your trial. Please try again later.');
}
Because the promise isn't awaited, the catch never sees a failed write, and the success message is logged before the file exists. If the write fails, the rejection is unhandled, and since Node 15 that ends the process partway through creating the project instead of logging the error and carrying on. The other writes in the same function (.env on line 158, .yarnrc.yml on 164, .gitignore on 227) are awaited.
A failed write here should be rare, so this is a small one, but the fix is one word.
Steps to Reproduce
I haven't run this end to end; it follows from the code. To see it, make that one write fail (for example, stub fse.writeFile to reject for license.txt) and create a project with the trial:
- Run
create-strapi-appwithshouldCreateGrowthSsoTrialon. - The license write rejects.
- The process exits with an unhandled rejection instead of logging "Error while trying to create your trial".
Expected Behavior
await fse.writeFile(join(rootPath, 'license.txt'), data.license);, so a failed write reaches the catch, and the message is logged only once the file is written.
Code Snippets
The same missing await is in four e2e tests. Playwright's next expect usually waits long enough for these to work, but a test can end before the action does, and an action that fails becomes an unhandled rejection rather than a failed step:
clickLoginTimes(6);, anasynchelper: https://github.com/strapi/strapi/blob/6ed1be0fd1a0d37f25a0e0a74ecac2bebb9f14f3/tests/e2e/tests/admin/login.spec.ts#L78previousVersion.click();: https://github.com/strapi/strapi/blob/6ed1be0fd1a0d37f25a0e0a74ecac2bebb9f14f3/tests/e2e/tests/content-manager/history.spec.ts#L181 and https://github.com/strapi/strapi/blob/6ed1be0fd1a0d37f25a0e0a74ecac2bebb9f14f3/tests/e2e/tests/content-manager/history.spec.ts#L200titleBox.fill('West Ham pre match jokes');: https://github.com/strapi/strapi/blob/6ed1be0fd1a0d37f25a0e0a74ecac2bebb9f14f3/tests/e2e/tests/content-manager/preview.spec.ts#L221
Each of these calls is awaited elsewhere in the same file.
Additional information
Found with Stratum Open's check for promises left unawaited.
- Dominant language
- TypeScript
- Stars
- 73.5k
- Forks
- 10k
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 276
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from strapi/strapi
-
Document service update() deep-populates the entry lookup, then only uses its idPossibly taken @hood claimed this 10 days ago. Openissue: bug severity: low source: core:core status: pending reproduction version: 5
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
strapi/strapi#28445 · 2 comments ·
Maintainers usually reply within 2 days
-
Content releases validate entries on every save, even when they are in no releasePossibly taken @hood claimed this 10 days ago. Openissue: bug severity: low source: core:content-releases status: pending reproduction version: 5
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
strapi/strapi#28443 · 3 comments ·
Maintainers usually reply within 2 days
-
Enumeration values used as component entry title are not translatedPossibly taken @breezertwo claimed this 10 days ago. Openissue: bug severity: low source: core:content-manager status: pending reproduction version: 5
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
upload: PUT /upload/settings drops autoOrientation when omitted from the request bodyPossibly taken @Adzouz claimed this 19 days ago. Openissue: bug severity: low source: core:upload version: 5
Difficulty 1/5 Under an hour Newbie friendliness 82/100
strapi/strapi#28228 · 3 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
issue: bug severity: low source: core:content-type-builder status: pending reproduction version: 5
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
strapi/strapi#28227 · 3 comments ·
Maintainers usually reply within 2 days
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
devswha/herdr-web-ui#3875 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
area: runtime chore cli consistency dependencies developer-experience difficulty: easy discovery documentation enhancement good first issue help wanted hygiene json-output packaging priority: P3 tests version
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
discovery:other factory-active task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
vercel/ai#25068 · 4 comments ·
Maintainers usually reply within 1 day
-
[Bug] Backend summarize min() / max() panics when a field has no numeric valuesPossibly taken @weng5e claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
grafana/grafana-infinity-datasource#1832 ·
Maintainers usually reply within 1 day