Skip to content

The client script's promise never settles on a page with no JavaScript property #24

Description

@jwrosewell

The problem

On a page whose response lists no JavaScript property at all, fod.promise
never settles. Page code that awaits it waits forever.

This is true on main today, so it is not something the create last
work introduced. It was found while that work was proved, and it is raised
here rather than fixed there because fixing it properly is its own change.

What was checked

JavaScriptResource.mustache on main at 13ba5e7, line 382, and on the
create last branch
(#23) at line
875. When processJsProperties starts no snippet, started stays at zero
and the branch releases its hold and sets the round complete without
calling the constructor's resolve
. The promise path never hears that the
round ended.

The identifier and every other value still arrive. update runs,
fod.fodid is published, and both onChange and complete fire. Only the
promise is left pending. That was driven by the template harness on the
create last branch, which has a case for a page with no JavaScript property,
and by the browser tests in
pipeline-dotnet#416,
which wait on complete() rather than on the promise for exactly this
reason.

Why it is not a one line fix

The obvious change is to call resolve in that branch. The constructor's
resolve is not reachable there, so it has to be threaded through. And once
threaded, a later failure on the same page view would try to reject a
promise that has already resolved, which does nothing, so a failure after a
no snippet round would be swallowed silently. The change has to decide which
of those two outcomes a page should see.

Until then

Page code should use fod.complete(callback) rather than awaiting
fod.promise. The template README could say so in one line.

Related

  • The create last programme, which is tracked internally
  • The template work package, #22

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: cleanupTidying that changes no behaviour

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions