Gutenberg: The editor has encountered an unexpected error. (solved by updating the try_files nginx configuration)

Created on 14 Sep 2018  ·  29Comments  ·  Source: WordPress/gutenberg

Bug Description
Cannot edit a post/draft, it shows 'the editor has encountered an unexpected error'.
Screenshot:
2018-09-14_21h52_36

This happen since upgraded to Gutenberg Version 3.8.0

I've been tried to

  • Disabled all plugins (included Yoast SEO) and browser addons.
  • Attempt recovery doesn't work

Error code
TypeError: Cannot read property 'show_ui' of undefined at http://ngonfig.io/wp-content/plugins/gutenberg/build/editor/index.js?ver=1536809587:12:260789 at i (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/lodash.min.59550321.js:6:91) at An.filter (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/lodash.min.59550321.js:99:338) at http://ngonfig.io/wp-content/plugins/gutenberg/build/editor/index.js?ver=1536809587:12:260754 at yh (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:95:430) at lg (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:120:88) at mg (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:120:386) at gc (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:127:202) at vb (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:126:230) at ub (http://ngonfig.io/wp-content/plugins/gutenberg/vendor/react-dom.min.82e21c65.js:126:65)

Environment

  • WordPress 4.9.8
  • Gutenberg 3.8.0
  • WordPress is running in localhost with Nginx

Now i'm working with gutenberg 3.7.0 downloaded from https://downloads.wordpress.org/plugin/gutenberg.3.7.0.zip

[Type] Help Request

Most helpful comment

Just to confirm, the following worked for me:

try_files $uri $uri/ /index.php$is_args$args;

@Zenexer & @benpbolton

All 29 comments

I've run across the same thing on two sites running on nginx. I've posted more details on my setup here: https://github.com/WordPress/gutenberg/issues/9876#issuecomment-421140966

It seems it may be an issue with running it on nginx. I've tested with a brand new install with no plugins, on a browser with guest mode with no plugins, and get the same.

In the screenshot, I see another error above this? Is it a request error?

@Taubin In one of the old Gutenberg issues, I did see something a mention of nginx and WordPress REST API not working properly by default unless some configuration is added to nginx, but I can't seem to find it at the moment.

@youknowriad that errors when attempting recovery.

react-dom.min.82e21c65.js:110 TypeError: Cannot read property 'show_ui' of undefined
    at index.js?ver=1537162302:12
    at i (lodash.min.59550321.js:6)
    at An.filter (lodash.min.59550321.js:99)
    at index.js?ver=1537162302:12
    at yh (react-dom.min.82e21c65.js:95)
    at lg (react-dom.min.82e21c65.js:120)
    at mg (react-dom.min.82e21c65.js:120)
    at gc (react-dom.min.82e21c65.js:127)
    at vb (react-dom.min.82e21c65.js:126)
    at ub (react-dom.min.82e21c65.js:126)

Using old version of gutenberg is not fixed that anymore (tried 3.7.0 --> 3.6.0 --> ... ) But it's okay when i switched to apache.

@danielbachhuber Do you have more context on the Nginx REST API issues and what needs to be done there?

@youknowriad I don't off the top of my head, no.

@Fathurhoho Can you share the contents of the REST API response? You're looking for the taxonomies?context=edit request in the "Network" tab.

image

@danielbachhuber this...
2018-09-17_22h18_20

dunno how to copy-paste the json, hope the pict is clear enough

@Fathurhoho Yes, this is helpful. Each object on the REST API response is expected to have a visibility attribute, which has show_ui nested underneath. For some reason, yours does not (nor does it have capabilities, etc.).

To confirm, this is a basic WordPress installation with Twenty Seventeen running and no active plugins?

If so, another problem this could be is that Nginx isn't passing ?context=edit back to PHP. It seems odd the problem would manifest itself this way (that so much of WordPress could load before this becomes an issue) but a missing ?context=edit would explain why only a subset of the expected data is included in the response.

To confirm, this is a basic WordPress installation with Twenty Seventeen running and no active plugins?

@danielbachhuber Yes.
Now i'm using a child theme and already tried to use another theme, still no effect.

For additional information, this is health check status:

                ### WordPress ###

Version: 4.9.8
Language: en_US
Permalink structure: /%postname%.html
Is this site using HTTPS?: No
Can anyone register on this site?: No
Default comment status: open
Is this a multisite?: No
User Count: 1
Communication with WordPress.org: WordPress.org is reachable
Create loopback requests: The loopback request to your site failed, this may prevent WP_Cron from working, along with theme and plugin editors.<br>Error encountered: (0) cURL error 6: Could not resolve host: ngonfig.io

### Installation size ###

Uploads Directory: 41.71 MB
Themes Directory: 3.91 MB
Plugins Directory: 16.44 MB
Database size: 2.61 MB
Whole WordPress Directory: 86.00 MB
Total installation size: 88.61 MB

### Active Theme ###

Name: Twenty Seventeen
Version: 1.7
Author: the WordPress team
Author website: https://wordpress.org/
Parent theme: Not a child theme
Supported theme features: automatic-feed-links, title-tag, post-thumbnails, menus, html5, post-formats, custom-logo, customize-selective-refresh-widgets, editor-style, starter-content, custom-header, widgets

### Other themes (4) ###

First (first): Version 2.0.4 by Takao Utsumi
First Child (firstchild): Version 2.0.4 by Fathur Saragih
Twenty Fifteen (twentyfifteen): Version 2.0 by the WordPress team
Twenty Sixteen (twentysixteen): Version 1.5 by the WordPress team

### Must Use Plugins (1) ###

Health Check Troubleshooting Mode: Version 1.5.0

### Active Plugins (1) ###

Health Check & Troubleshooting: Version 1.2.1 by The WordPress.org community

### Inactive Plugins (3) ###

Gutenberg: Version 3.8.0 by Gutenberg Team
Tabby Responsive Tabs: Version 1.2.3 by cubecolour
Yoast SEO: Version 8.2 by Team Yoast

### Media handling ###

Active editor: WP_Image_Editor_GD
Imagick Module Version: Imagick not available
ImageMagick Version: Imagick not available
GD Version: 2.2.5
Ghostscript Version: Not available

### Server ###

Server architecture: Linux 4.4.0-131-generic x86_64
PHP Version: 7.0.31-1+ubuntu16.04.1+deb.sury.org+1 (Supports 64bit values)
PHP SAPI: fpm-fcgi
PHP max input variables: 1000
PHP time limit: 30
PHP memory limit: 256M
Max input time: 60
Upload max filesize: 2M
PHP post max size: 8M
cURL Version: 7.47.0 OpenSSL/1.0.2g
SUHOSIN installed: No
Is the Imagick library available: No

### Database ###

Extension: mysqli
Server version: 5.5.5-10.0.34-MariaDB-0ubuntu0.16.04.1
Client version: mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
Database prefix: wp_

### WordPress Constants ###

ABSPATH: /usr/share/nginx/ngonfig.net/
WP_HOME: Undefined
WP_SITEURL: Undefined
WP_DEBUG: Disabled
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG_DISPLAY: Enabled
WP_DEBUG_LOG: Disabled
SCRIPT_DEBUG: Disabled
WP_CACHE: Disabled
CONCATENATE_SCRIPTS: Undefined
COMPRESS_SCRIPTS: Undefined
COMPRESS_CSS: Undefined
WP_LOCAL_DEV: Undefined

### Filesystem Permissions ###

The main WordPress directory: Writable
The wp-content directory: Writable
The uploads directory: Writable
The plugins directory: Writable
The themes directory: Writable
The Must Use Plugins directory: Writable

nginx version

$ nginx -V
nginx version: nginx/1.10.3 (Ubuntu)
built with OpenSSL 1.0.2g  1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads

PHP version:

$ php -v
PHP 7.2.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 19 2018 07:16:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Just switched to php7.2 and still same.

Hi
Same issue here
Gutember 3.8
Wordpress 4.9.8
nginx 1.15.3
php-fpm 7.1
No matter if plugins are enabled or disaled nor what theme I use.
I get this error log:
TypeError: Cannot read property 'show_ui' of undefined
at index.js:1
at i (lodash.min.59550321.js:1)
at An.filter (lodash.min.59550321.js:1)
at index.js:1
at yh (react-dom.min.82e21c65.js:95)
at lg (react-dom.min.82e21c65.js:120)
at mg (react-dom.min.82e21c65.js:120)
at gc (react-dom.min.82e21c65.js:127)
at vb (react-dom.min.82e21c65.js:126)
at ub (react-dom.min.82e21c65.js:126)
bg @ react-dom.min.82e21c65.js:110
d.function.d.componentDidCatch.c.callback @ react-dom.min.82e21c65.js:116
Jf @ react-dom.min.82e21c65.js:73
Kf @ react-dom.min.82e21c65.js:74
jc @ react-dom.min.82e21c65.js:134
gc @ react-dom.min.82e21c65.js:127
vb @ react-dom.min.82e21c65.js:126
ub @ react-dom.min.82e21c65.js:126
zd @ react-dom.min.82e21c65.js:124
ra @ react-dom.min.82e21c65.js:123
enqueueSetState @ react-dom.min.82e21c65.js:189
q.setState @ react.min.ab6b06d4.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
h @ index.js:1
(anonymous) @ index.js:1
tryCatch @ wp-polyfill-ecmascript.min.2ae96136.js:1
invoke @ wp-polyfill-ecmascript.min.2ae96136.js:1
t.(anonymous function) @ wp-polyfill-ecmascript.min.2ae96136.js:1
r @ index.js:1
c @ index.js:1
Promise.then (async)
r @ index.js:1
c @ index.js:1
Promise.then (async)
r @ index.js:1
c @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
d @ index.js:1
y @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
r @ index.js:1
n @ index.js:1
yh @ react-dom.min.82e21c65.js:97
lg @ react-dom.min.82e21c65.js:120
mg @ react-dom.min.82e21c65.js:120
gc @ react-dom.min.82e21c65.js:127
vb @ react-dom.min.82e21c65.js:126
ub @ react-dom.min.82e21c65.js:126
zd @ react-dom.min.82e21c65.js:124
ra @ react-dom.min.82e21c65.js:123
enqueueSetState @ react-dom.min.82e21c65.js:189
q.setState @ react.min.ab6b06d4.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
h @ index.js:1
(anonymous) @ index.js:1
tryCatch @ wp-polyfill-ecmascript.min.2ae96136.js:1
invoke @ wp-polyfill-ecmascript.min.2ae96136.js:1
t.(anonymous function) @ wp-polyfill-ecmascript.min.2ae96136.js:1
r @ index.js:1
c @ index.js:1
Promise.then (async)
r @ index.js:1
c @ index.js:1
Promise.then (async)
r @ index.js:1
c @ index.js:1
Promise.then (async)
r @ index.js:1
c @ index.js:1
Promise.then (async)
r @ index.js:1
c @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
d @ index.js:1
y @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
r @ index.js:1
n @ index.js:1
yh @ react-dom.min.82e21c65.js:97
lg @ react-dom.min.82e21c65.js:120
mg @ react-dom.min.82e21c65.js:120
gc @ react-dom.min.82e21c65.js:127
vb @ react-dom.min.82e21c65.js:126
ub @ react-dom.min.82e21c65.js:126
zd @ react-dom.min.82e21c65.js:124
ra @ react-dom.min.82e21c65.js:123
Id @ react-dom.min.82e21c65.js:138
kc @ react-dom.min.82e21c65.js:138
Sa.render @ react-dom.min.82e21c65.js:194
(anonymous) @ react-dom.min.82e21c65.js:141
Hd @ react-dom.min.82e21c65.js:136
mc @ react-dom.min.82e21c65.js:141
render @ react-dom.min.82e21c65.js:196
Rn @ index.js:1
(anonymous) @ post.php?post=8133&action=edit:4631

and in the nginx log, call to json are ok, like this

GET /om/wp-json/wp/v2/taxonomies?per_page=-1&context=edit HTTP/2.0" 200 256 "https://mysite.com/wp-admin/post-new.php?gutenberg-demo"

Solved my issue with:

Content-Security-Policy: worker-src 'self' *.sterm.org data: blob:;

previously I have

Content-Security-Policy: worker-src 'self' data: blob: *.sterm.org ;

PD: Solved in main domain but still here in wordpress sites running as folders, but error is something different:

P.D. 2: Solved in sites running as folders. The issue was a misconfiguration in nginx:
try_files $uri $uri/ /om/index.php$is_args$args ;

The $is_args$args part are missing.

@Fathurhoho @Taubin, did @Lofesa's notes about Content-Security-Policy headers in nginx help you?

@Lofesa thank you for the notes!

The $is_args$args addition to try_files did it for me. CSP didn't make a difference.

Just a note here that nginx configuration templates don't reference try_files directives in this manner; if Gutenberg is going to require

    try_files $uri $uri/ /index.php$is_args$args;

then associated references like:

... may need updating

Just to confirm, the following worked for me:

try_files $uri $uri/ /index.php$is_args$args;

@Zenexer & @benpbolton

Hi, it's a very old bug. And try_files $uri $uri/ /index.php$is_args$args; and the CSP don't work for my yet. Note that changing the permalink to simple resolve the bug. But for now, i will not use Gutenberg until it's fully fixed.

I had the same issue, I'm using NGINX and indeed I was missing $args from try_files directive.

This does not work for me.

        location /plugins/ {
                try_files $uri $uri/ /plugins/index.php$is_args$args;
        }

Does not work ...

@danielbarenkamp add to root

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

@daliborgogic That does not work. My installation is laying in a subfolder.

My name is nginx. I use is_args to solve this problem.
old try_files $uri $uri/ index.php?Args;
new try_files $uri $uri/ index.php $is_args $args;

Just had this error after updating to the WordPress Version 5.1

This solved my problem.
Update nginx conf file

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

Thinks you for the way .I’ve settled it right now

在 2019年3月6日,下午12:13,leotanty notifications@github.com 写道:

Just had this error after updating to the WordPress Version 5.1

This solved my problem.
Update nginx conf file

location / { try_files $uri $uri/ /index.php$is_args$args; }


You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/WordPress/gutenberg/issues/9912#issuecomment-469961378, or mute the thread https://github.com/notifications/unsubscribe-auth/AD6UJKuRm7mxg92N-Boi0RLjn2BIuuuVks5vT0BygaJpZM4Wpboa.

Just had this error after updating to the WordPress Version 5.1

This solved my problem.
Update nginx conf file

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

this works. thanks.
but i got another problem
publishing failed

This "patch" doesn't work for me, here is my nginx config :

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ .php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}

Is there any other patch ... ?

Doesn't work for me either.

Edited my server config file
still getting REST API Time out

This "patch" doesn't work for me, here is my nginx config :

location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ .php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}

Is there any other patch ... ?

Maybe your problen is:
location ~ .php$ {
The $ makes the end of line, so index.php?some-thing don´t match the location.

Install and enable the classic editor plugin. It helped me get rid of this mistake.

@benpbolton 's suggestion worked for me, but with automattics supercache the 'try_files' - line should look like:
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index-https.html $uri $uri/ /index.php$is_args$args;

Legit Solution: This problem is actually caused due to old invalid cache that's being served to your browser when you try to access those resources after updating certain plugins or the core WordPress software. I know, WordPress caching plugins do not serve cache when the user is logged in, but there are other services such as Cloudflare (or any other CDN), your browser and sometimes your host that maybe serving the old invalid cache,

Thus, the simplest way to fix the problem is, clear cache from these places:

  1. Your browser
  2. Your WordPress caching plugin
  3. Cloudflare (or any other CDN that you are using)
  4. Your Host

I have written an easy to follow step by step guide on the same, please check that out: (FIXED) The Editor Has Encountered An Unexpected Error WordPress

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidsword picture davidsword  ·  3Comments

mhenrylucero picture mhenrylucero  ·  3Comments

jasmussen picture jasmussen  ·  3Comments

pfefferle picture pfefferle  ·  3Comments

spocke picture spocke  ·  3Comments