Skip to content

Interactive API async event deprecation message shows when the action is wrapped with withSyncEvent() in scripts debug mode #70159

@wongjn

Description

@wongjn

Description

As per Interactivity API best practices in 6.8:

Starting in WordPress 6.8, if any action callback uses the above event properties or methods and is not wrapped in withSyncEvent(), that action callback will trigger a deprecation warning.

However, it seems withSyncEvent() has no effect with regard to this when SCRIPT_DEBUG is set to true. The deprecation warning shows regardless. I was able to produce this with custom blocks as well as the built-in core/query structure of blocks.

Step-by-step reproduction instructions

  1. Add define( 'SCRIPT_DEBUG', true ); in wp-config.php.
  2. Generate many posts, i.e. in WP CLI wp post generate
  3. Add the following to a page:
    <!-- wp:query {"queryId":1,"query":{"perPage":1,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[],"format":[]},"enhancedPagination":true} -->
      <div class="wp-block-query">
        <!-- wp:post-template -->
          <!-- wp:post-title /-->
        <!-- /wp:post-template -->
    
        <!-- wp:query-pagination -->
          <!-- wp:query-pagination-previous /-->
    
          <!-- wp:query-pagination-numbers /-->
    
          <!-- wp:query-pagination-next /-->
        <!-- /wp:query-pagination -->
      </div>
    <!-- /wp:query -->
  4. Click on a pagination link.
  5. See the deprecation message show.

Screenshots, screen recording, code snippet

Seems to be due to the getEvaluate() in debug.js:

return (...functionArgs) => {
  setScope(scope);
  const functionResult = value(...functionArgs);
  resetScope();
  return functionResult;
};

This loses the sync property that withSyncEvent() adds to the store method/function.

Environment info

  • WordPress 6.8.1
  • Chrome 136.0.7103.114 (Official Build) (64-bit)

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Interactivity APIAPI to add frontend interactivity to blocks.[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions