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

Intermittent SQLite Database Disconnects #1596

Closed
adamziel opened this issue Jul 10, 2024 · 3 comments · Fixed by #2119
Closed

Intermittent SQLite Database Disconnects #1596

adamziel opened this issue Jul 10, 2024 · 3 comments · Fixed by #2119
Labels
[Priority] High [Type] Bug An existing feature does not function as intended

Comments

@adamziel
Copy link
Collaborator

Playground randomly "disconnects" from SQLite. This issue was reported by:

Here's the error log provided by Pascal:

Error: PHP.run() failed with exit code 255 and the following output: 
    at _NodePHP.run (/Users/pascalb/Workspace/WordPress/media-experiments/node_modules/@php-wasm/node/index.cjs:72937:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async #dispatchToPHP (/Users/pascalb/Workspace/WordPress/media-experiments/node_modules/@php-wasm/node/index.cjs:72470:14)
    at async PHPRequestHandler.request (/Users/pascalb/Workspace/WordPress/media-experiments/node_modules/@php-wasm/node/index.cjs:72385:14)
    at async PHPBrowser.request (/Users/pascalb/Workspace/WordPress/media-experiments/node_modules/@php-wasm/node/index.cjs:72170:22)
    at async file:///Users/pascalb/Workspace/WordPress/media-experiments/node_modules/@wp-now/wp-now/main.js:945:20 {
  output: {
    stdout: '<!DOCTYPE html>\n' +
      '<html lang="en-US">\n' +
      '<head>\n' +
      '\t<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n' +
      '\t<meta name="viewport" content="width=device-width">\n' +
      '\t\t',
    stderr: ''
  },
  source: 'request'
}
@WunderBart
Copy link
Member

WunderBart commented Sep 25, 2024

We may be experiencing a similar issue in Woo using wp-env. For example, a seemingly random Error establishing a database connection error is thrown when we attempt to activate a plugin in the beforeEach hook of a (Playwright) test. We have a flaky report for a test that has been throwing this error much more than others: woocommerce/woocommerce#51101. Here's the payload:

image

I'm currently investigating it at woocommerce/woocommerce#51658.

FYI, I've also found WordPress/gutenberg#62242, which describes a similar issue.

cc: @carstingaxion

@adamziel
Copy link
Collaborator Author

Oooh interesting @WunderBart, thank you so much for sharing!

@adamziel
Copy link
Collaborator Author

adamziel commented Nov 28, 2024

In wp-now and in some @wp-playground/cli configurations this is caused by rotating the PHP runtime. The hotSwapPHPRuntime does not recreate the NODEFS mounts so they're lost, meaning WordPress can no longer see the local wp-content where the SQLite file lives. That would also explain playground.wordpress.net when OPFS is involved. That's already a lot to work with.

playground.wordpress.net + MEMFS remains a mystery.

adamziel added a commit that referenced this issue Jan 9, 2025
 Re-create the mounts destroyed during the hotSwapPHPRuntime call.
 Closes #1596

  ## Context
  Without this PR, `hotSwapPHPRuntime()` does not:   * Recreate the filesystem mounts * Restore the platform-level plugins stored in the /internal (e.g the
   SQLite integration plugin)

 Which results in WordPress losing access to local files and the database connectivity.

 This PR ensures the mounts are re-created and the platform-level plugins
 preserved.

  ## Testing instructions

 This PR comes with tests, so check the CI logs.
@github-project-automation github-project-automation bot moved this from Backlog to Done in Playground Board Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] High [Type] Bug An existing feature does not function as intended
Projects
Archived in project
2 participants