Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞SPFx v1.15 (and prior) - gulp serve race condition #8258

Open
4 of 9 tasks
andrewconnell opened this issue Jul 1, 2022 · 3 comments
Open
4 of 9 tasks

🐞SPFx v1.15 (and prior) - gulp serve race condition #8258

andrewconnell opened this issue Jul 1, 2022 · 3 comments
Labels
area:spfx Category: SharePoint Framework (not extensions related) status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@andrewconnell
Copy link
Collaborator

andrewconnell commented Jul 1, 2022

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

macOS

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version: observed in all the above selected latest versions, but doesn't appear to be browser dependent
  • SPFx version: v1.14 & v1.15
  • Node.js version: v16
  • Platform: macOS & Windows

Describe the bug / error

This happened periodically before, but with SPFx v1.15 it's happening 100% of the time. I verified this with other developers first.

When running gulp serve, the build toolchain launches the external browser with the default testing URL of the hosted workbench at the start of the tasks, but if the browser loads the hosted workbench before the local webserver is running to serve up the manifest.js file, the workbench reports the following error:

Screen Shot 2022-07-01 at 5 11 06 PM

This is because the local build toolchain hasn't finished building & thus spinning up the local webserver to serve up the manifest.js file. Classic definition of a race condition.

I observed this happening prior to 1.15 but not with much frequency. Now I see it 100% of the time on multiple machines. Looking at the definition of the serve task, it's running tasks in serial and the first one is the serve task.

💡 Proposed solution

Change the order of the tasks - only start the gulp serve task AFTER the local project is built & the web server is running.

The serve task is defined in the NPM package @microsoft/sp-build-web v1.15.0... specifically look at the generated JS:

./lib/SPWebBuildRig.js line 124:

result.set(WebBuildRigConstants_1.WebBuildRigConstants.tasks.serve, {
    executable: (0, gulp_core_build_1.serial)(spBuildCoreTasks.serve, (0, gulp_core_build_1.watch)(exports.serveWatchFilter, (0, gulp_core_build_1.serial)(this._preTelemetryTask, result.get(WebBuildRigConstants_1.WebBuildRigConstants.tasks.bundle).executable, gulp_core_build_serve_1.reload, this._postTelemetryTask))),
    arguments: (yargs) => { .. }
});

The beginning of the executable property shows how it's running tasks in serial, starting with the serve task.

Steps to reproduce

  1. Create new SPFx project (any type of component)
  2. Edit the ./config/serve.json to point to your hosted workbench.
  3. Execute gulp serve
  4. Observe the error displayed above

Workaround

  1. Kick kitten 🐈
  2. Wait until the console gets to the internal gulp task reload
  3. Refresh the workbench in the server, now works as expected, because now the server is working

Expected behavior

Workbench wouldn't load until AFTER the local webserver has started and can serve up the built files.

@andrewconnell andrewconnell added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Jul 1, 2022
@ghost
Copy link

ghost commented Jul 1, 2022

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 Awaiting categorization and initial review. label Jul 1, 2022
@VesaJuvonen VesaJuvonen added area:spfx Category: SharePoint Framework (not extensions related) and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Jul 4, 2022
@AJIXuMuK AJIXuMuK added the status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. label Jul 5, 2022
@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Jul 5, 2022

Thanks @andrewconnell for reporting the issue!
We're working on the fix.

@matteogrechi
Copy link

Any news about on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:spfx Category: SharePoint Framework (not extensions related) status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

4 participants