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

Unhandled "TypeError: Cannot convert undefined or null to object" on new environment #259

Closed
RWareSteve opened this issue May 9, 2024 · 3 comments
Assignees
Labels
Bug Something isn't working wp-now

Comments

@RWareSteve
Copy link

Here some details about the system I've setup:

...
date : "2023-10-25",
time : "12:25:59",
os_group : "Linux",
os_distribution : "ubuntu",
os_distribution_version : "Ubuntu 22.04.2 LTS",
os_based_distribution : "debian",
os_based_distribution_version : "22.04",
os_kernel : "5.15.90.1-microsoft-standard-WSL2",
os_detailed_kernel : "Linux LenovoLap 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux",
cpus_total : "1",
cores_total : "2",
cpu_types : "Intel(R)Core(TM)i7-3537UCPU@2.00GHz",
cpu_architecture : "x86_64",
ram_total : "4954888",
disk_total : "1102040084480",
...

npm --version
10.5.0

node -v
v20.12.2

php --version
PHP 8.1.2-1ubuntu2.17 (cli) (built: May 1 2024 10:10:07) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.17, Copyright (c), by Zend Technologies

wp-now --version
0.1.70

I only run following steps
cd ~
= /home/wpdevuser
mkdir dev
cd dev
mkdir demodir
cd demodir

and launched wp-now for the first time
wp-now start

wp-version
6.5.3

I opened the browser and called the website, (automatically login (admin / password):
after 3 clicks an error happens:
click on Pages
click on Sample Page
click on View Pages, no changes, only icon left upper corner click to return to previous page

following error is shown on console where "wp-now start" was launched:

...
Server running at http://localhost:8881
Trace: TypeError: Cannot convert undefined or null to object
at Function.entries ()
at encodeAsMultipart (file:///home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/main.js:922:38)
at file:///home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/main.js:994:33
at Layer.handle [as handle_request] (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:328:13)
at /home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:286:9
at Function.process_params (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:346:12)
at next (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:280:10)
at file:///home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/main.js:897:7
at Layer.handle [as handle_request] (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:328:13)
at /home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:286:9
at Function.process_params (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:346:12)
at next (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/index.js:280:10)
at compression (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/compression/index.js:220:5)
at Layer.handle [as handle_request] (/home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/node_modules/express/lib/router/layer.js:95:5)
at file:///home/wpdevuser/.nvm/versions/node/v20.12.2/lib/node_modules/@wp-now/wp-now/main.js:1017:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The same happens if you click on posts, on one post and on View Posts = icon left upper corner.

The main reason to build the wp-now environment was to develop a new plugin, here "demodir".
This folder is on call of "wp-now start" empty. So after getting the error and adding some test files to "demodir" the same issue happened.

Can I ignore this error ?

@RWareSteve
Copy link
Author

Sorry, I forgot to share: I don't have Playground installed, just wp-now.

@adamziel adamziel added Bug Something isn't working wp-now labels May 13, 2024
sejas pushed a commit that referenced this issue May 15, 2024
<!-- Thanks for contributing to WordPress Playground Tools! -->

## What?

<!-- In a few words, what is the PR actually doing? Include screenshots
or screencasts if applicable -->

Drop manually encoding multipart requests. This PR is a follow-up of
#203.

## Why?

<!-- Why is this PR necessary? What problem is it solving? Reference any
existing previous issue(s) or PR(s), but please add a short summary
here, too -->

This PR follows [this
discussion](#203 (comment))
regarding the necessity of manually encoding multipart requests.
Additionally, it addresses
#259.

## How?

<!-- How is your PR addressing the issue at hand? What are the
implementation details? -->

- Remove Express `fileUpload` middleware to avoid modifying the request
object.
- Remove `encodeAsMultipart` helper, since we don't need to process them
differently ([Playground CLI
example](https://github.com/WordPress/wordpress-playground/blob/946dd7225cec1b5bebbe33072b246609d9e4524a/packages/playground/cli/src/server.ts#L28-L41)).

## Testing Instructions

<!-- Please include step by step instructions on how to test this PR.
-->
<!-- 1. Check out the branch. -->
<!-- 2. Run a command. -->
<!-- 3. etc. -->

1. Run the command: `nvm use && npm install`.
2. Run the command `nx preview wp-now start`.
3. Open the WP-admin page (e.g. `http://localhost:8881/wp-admin`).
4. Navigate to the Media page.
5. Upload a media file.
6. Observe the media has been uploaded correctly to the Media Library.
@sejas
Copy link
Collaborator

sejas commented May 21, 2024

@RWareSteve, Thanks for reporting the issue. We have fixed it and released wp-now v0.1.71. You can try it by executing npx @wp-now/wp-now@latest start.

I confirmed that the error is gone on my side, so I'll close this issue. If it's not fixed on your end, just let me know.

Thanks again for reporting! wp-now is now better thanks to your help. 🙌

@sejas sejas closed this as completed May 21, 2024
@sejas sejas self-assigned this May 21, 2024
@RWareSteve
Copy link
Author

RWareSteve commented May 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working wp-now
Projects
None yet
Development

No branches or pull requests

3 participants