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

"parsererror" toast messages when opening a page in the CMS #141

Closed
robbieaverill opened this issue Jul 25, 2018 · 25 comments
Closed

"parsererror" toast messages when opening a page in the CMS #141

robbieaverill opened this issue Jul 25, 2018 · 25 comments

Comments

@robbieaverill
Copy link
Contributor

Version: CWP 2.0.1 and CWP 2.1.0-rc2

Context: I have two fluent locales and two subsites with a variety of pages created in each.

Tested on a vanilla CWP 2.0.1 and CWP 2.1.0-rc2 code base.

When I log into the CMS, go to Campaigns, go back to Pages again and click on one of the pages in the tree, I see a success toast message in the top right corner saying "parsererror".

This appears to come from jQuery or jQuery changetracker somewhere, but I wasn't able to find out why at a quick investigation.

image

@robbieaverill
Copy link
Contributor Author

@micmania1 mentioned that he's seen this on a private project using SilverStripe 4 on SilverStripe Platform, but not using CWP. This could mean it's caused either by core and/or by one of the CWP modules, but not directly by CWP itself.

@micmania1
Copy link
Contributor

micmania1 commented Jul 25, 2018

composer info -D

benmanu/silverstripe-simple-styleguide 2.0.3                          Provides a kitchen sink template useful for theme development.
dnadesign/silverstripe-populate        dev-feature/ss4-compat 19128ab Populate your database through YAML files
heyday/silverstripe-menumanager        3.0.3                          Allows complex menu management to be handled through the CMS when a simple tree structure is not enough.
lekoala/silverstripe-debugbar          dev-master ddbfddb             DebugBar for SilverStripe CMS
phpunit/phpunit                        5.7.27                         The PHP Unit Testing framework.
sheadawson/silverstripe-linkable       2.0.0                          A couple of handy form fields and objects for managing external and internal links on DataObjects
silverstripe/asset-admin               1.1.1                          Asset management for the SilverStripe CMS
silverstripe/cms                       4.1.2                          The SilverStripe Content Management System
silverstripe/comments                  3.1.x-dev 19619b0              This module provides commenting functionality for Pages and other DataObjects on your SilverStripe site.
silverstripe/crontask                  2.0.0                          Module for running tasks with a standard cron timeschedule
silverstripe/dynamodb                  4.0.1                          SilverStripe DynamoDB integration.
silverstripe/environmentcheck          2.0.0                          Provides an API for building environment tests
silverstripe/errorpage                 1.1.2                          ErrorPage component for SilverStripe CMS
silverstripe/framework                 4.1.2                          The SilverStripe framework
silverstripe/raygun                    dev-master da39347             RayGun.io integration for SilverStripe
undefinedoffset/sortablegridfield      2.0.5                          Adds drag and drop functionality to SilverStripe 4.x's GridField

These are what we're directly pulling in.

composer.json

	"require": {
		"php": ">=5.6",
		"silverstripe/cms": "^4.1",
		"silverstripe/framework": "^4",
		"silverstripe/dynamodb": "^4",
		"silverstripe/crontask": "^2",
		"silverstripe/environmentcheck": "^2",
		"silverstripe/asset-admin": "^1",
		"silverstripe/raygun": "^2",
		"benmanu/silverstripe-simple-styleguide": "^2.0",
		"heyday/silverstripe-menumanager": "^3.0",
		"dnadesign/silverstripe-populate": "dev-feature/ss4-compat",
		"sheadawson/silverstripe-linkable": "^2.0",
		"undefinedoffset/sortablegridfield": "^2.0",
		"silverstripe/comments": "3.1.x-dev",
		"silverstripe/errorpage": "^1.1"
	},
	"require-dev": {
		"phpunit/phpunit": "^5.7",
		"lekoala/silverstripe-debugbar": "2.0.x-dev"
	},

@robbieaverill robbieaverill self-assigned this Jul 26, 2018
@robbieaverill
Copy link
Contributor Author

robbieaverill commented Jul 26, 2018

I suspect this is related to the comments module somehow. I can't reproduce it on mediumtest-uat (running CWP 2.1.0) unless I open a page that has comments enabled on it.

Unfortunately I still can't reproduce this locally using the same code base with SS_ENVIRONMENT_TYPE="test" (like mediumtest-uat) and https enabled. I'll keep trying though.

Steps to reproduce on UAT:

  • Log into the CMS
  • Create a blog page
  • Create a blog post under it (which has comments enabled in CWP 2.1.0)
  • Go to "Campaigns"
  • Go back to "Pages"
  • Open the blog page
  • Click on the blog post in the lumberjack GridField
  • See the notification

From here you can toggle between the blog and the blog post in the SiteTree to continue to get the error.

It's worth noting that this doesn't happen if you refresh your browser and toggle between the pages in the SiteTree, so perhaps it's an issue with something that is or isn't loaded via AJAX when switching from campaigns into the CMS, which is or isn't loaded when you load the CMS edit URL directly.

@robbieaverill
Copy link
Contributor Author

Update: it looks like it's being caused by the colymba/gridfield-bulk-editing-tools module trying to load its Javascript file via PJAX. Removing the Requirements calls from the module removes the errors.

@robbieaverill
Copy link
Contributor Author

Update: colymba/gridfield-bulk-editing-tools 3.0.0-beta2 doesn't cause the problem. Must be caused by something between silverstripe/silverstripe-gridfield-bulk-editing-tools@3.0.0-beta2...3.0.0-beta3

@robbieaverill
Copy link
Contributor Author

This could be the same problem: silverstripe/silverstripe-gridfield-bulk-editing-tools#176

@jakedaleweb
Copy link

jakedaleweb commented Sep 27, 2018

Seeing the same "parsererror" on an SSP site. Required modules:

silverstripe/framework 4.1.0

"silverstripe/recipe-plugin": "^1",
"silverstripe/recipe-cms": "1.1.0@stable",
"sendgrid/sendgrid": "^6.0",
"symbiote/silverstripe-gridfieldextensions": "^3.0",
"silverstripe/crontask": "^2.0",
"silverstripe/dynamodb": "^4.0",
"silverstripe/staticpublishqueue": "dev-master",
"unclecheese/display-logic": "^2.0"

What i've found is that in this case, it only occurs when accessing the site via the CloudFlare CDN (i.e. if you bypass there's no error) - perhaps you only see this on CWP due to Incapsula?

I was able to resolve by deploying 3.22.2 which ensures the same timestamp on files over distributed servers - https://docs.platform.silverstripe.com/changelog/#3-22-2-12-september-2018

In this case it was a request to resources/vendor/silverstripe/admin/client/dist/js/vendor.js?m=1537450344&_=1538083876830 which was triggering the issue

@robbieaverill
Copy link
Contributor Author

@jakedaleweb thanks - that would make sense as to why it's not reproducible locally. Do you have any ideas about fixing this from a platform angle?

@jakedaleweb
Copy link

@robbieaverill Well the fix on SSP was to ensure that all servers in the load balance pool had the same modified times on the files as this is something required by core (I think ?).

However in the case of mediumtest it is a single server, so not impacted by the same issue.

So essentially, the issue I encountered has already been fixed on SSP by manifest version 3.22.2 and I don't believe it has the same cause as the issue you've described.

@chillu
Copy link
Member

chillu commented Oct 18, 2018

We’ve made this logic more stable on multi-server environments by ignoring the file modification time parameter when computing client-side requirements via jquery.ondemand. This is due to be released with 4.3.0 in a few weeks. silverstripe/silverstripe-framework#8346

Can you check if all of the environments having this issue are load balanced, and could be prone to having file generation timestamps getting out of date between filesystem copies in different webservers?

@amolswnz
Copy link

amolswnz commented Oct 18, 2018

My composer info output

asyncphp/doorman                                 3.0.0                                         Child process management
aws/aws-sdk-php                                  3.69.3                                        AWS SDK for PHP - Use Ama...
behat/gherkin                                    v4.5.1                                        Gherkin DSL parser for PH...
benmanu/silverstripe-simple-styleguide           2.0.5                                         Provides a kitchen sink t...
codeception/codeception                          2.5.0                                         BDD-style testing framework
codeception/phpunit-wrapper                      6.0.12                                        PHPUnit classes used by C...
codeception/stub                                 2.0.4                                         Flexible Stub wrapper for...
composer/ca-bundle                               1.1.2                                         Lets you find a path to t...
composer/installers                              v1.6.0                                        A multi-framework Compose...
composer/semver                                  1.4.2                                         Semver library that offer...
composer/xdebug-handler                          1.3.0                                         Restarts a process withou...
dnadesign/silverstripe-elemental                 2.1.2                                         Elemental pagetype and co...
dnadesign/silverstripe-elemental-userforms       1.0.0                                         Adds a new element for us...
doctrine/annotations                             v1.4.0                                        Docblock Annotations Parser
doctrine/cache                                   v1.6.2                                        Caching library offering ...
doctrine/instantiator                            1.0.5                                         A small, lightweight util...
doctrine/lexer                                   v1.0.1                                        Base library for a lexer ...
embed/embed                                      v3.3.6                                        PHP library to retrieve p...
facebook/webdriver                               1.6.0                                         A PHP client for Selenium...
firesphere/googlemapsfield                       dev-feature/multiple-per-form 7ed6078         Google places api field f...
firesphere/partialuserforms                      0.11                                          Store partial userform su...
firesphere/rangefield                            dev-master 644eae2                            Range selector for Silver...
firesphere/seeder                                dev-master 9f5df57                            Simplified seeding of the...
friendsofphp/php-cs-fixer                        v2.13.0                                       A tool to automatically f...
graze/monolog-extensions                         1.6.0                                         Monolog extensions for us...
guzzlehttp/guzzle                                6.3.3                                         Guzzle is a PHP HTTP clie...
guzzlehttp/promises                              v1.3.1                                        Guzzle promises library
guzzlehttp/psr7                                  1.4.2                                         PSR-7 message implementat...
ichaber/silverstripe-swiftype                    0.1.3                                         Use Swiftype search with ...
intervention/image                               2.4.2                                         Image handling and manipu...
jdorn/sql-formatter                              dev-master 7ef9b85                            a PHP SQL highlighting li...
jeremeamia/SuperClosure                          2.4.0                                         Serialize Closure objects...
jonom/focuspoint                                 3.0.0                                         Smarter automatic image c...
jonom/silverstripe-betternavigator               4.1.1                                         Front-end utility menu fo...
league/csv                                       8.2.3                                         Csv data manipulation mad...
league/flysystem                                 1.0.47                                        Filesystem abstraction: M...
lekoala/silverstripe-debugbar                    2.0.0                                         DebugBar for SilverStripe...
m1/env                                           2.1.2                                         Env is a lightweight libr...
marcj/topsort                                    1.1.0                                         High-Performance TopSort/...
maximebf/debugbar                                v1.15.0                                       Debug bar in the browser ...
mindscape/raygun4php                             v1.8.2                                        Raygun.io client for PHP ...
monolog/monolog                                  1.23.0                                        Sends your logs to files,...
mtdowling/cron-expression                        v1.2.1                                        CRON for PHP: Calculate t...
mtdowling/jmespath.php                           2.4.0                                         Declaratively specify how...
myclabs/deep-copy                                1.7.0                                         Create deep copies (clone...
nikic/php-parser                                 v3.1.5                                        A PHP parser written in PHP
nzta/silverstripe-sitebanner                     dev-master 0116a42                            Site-wide banners activat...
paragonie/random_compat                          v2.0.17                                       PHP 5.x polyfill for rand...
scriptfusion/phpunit-immediate-exception-printer 2.0.0                                         Immediately prints except...
sebastian/code-unit-reverse-lookup               1.0.1                                         Looks up which function o...
sebastian/comparator                             1.2.4                                         Provides the functionalit...
sebastian/diff                                   1.4.3                                         Diff implementation
sebastian/environment                            2.0.0                                         Provides functionality to...
sebastian/exporter                               2.0.0                                         Provides the functionalit...
sebastian/global-state                           1.1.1                                         Snapshotting of global state
sebastian/object-enumerator                      2.0.1                                         Traverses array structure...
sebastian/recursion-context                      2.0.0                                         Provides functionality to...
sebastian/resource-operations                    1.0.0                                         Provides a list of PHP bu...
sebastian/version                                2.0.1                                         Library that helps with m...
silverleague/ideannotator                        3.0.0                                         Generate PHP DocBlock ann...
silvershop/silverstripe-hasonefield              2.0-alpha2                                    Edit a has_one relationsh...
silverstripe/admin                               1.1.2                                         SilverStripe admin interface
silverstripe/asset-admin                         1.1.2                                         Asset management for the ...
silverstripe/assets                              1.1.2                                         SilverStripe Assets compo...
silverstripe/blog                                3.2.1                                         A fresh take on blogging ...
silverstripe/campaign-admin                      1.1.2                                         SilverStripe campaign adm...
silverstripe/cms                                 4.1.2                                         The SilverStripe Content ...
silverstripe/config                              1.0.4                                         SilverStripe configuratio...
silverstripe/crontask                            2.1.0                                         Module for running tasks ...
silverstripe/dynamodb                            4.0.1                                         SilverStripe DynamoDB int...
silverstripe/elemental-blocks                    1.0.0                                         A collection of CMS block...
silverstripe/environmentcheck                    2.0.0                                         Provides an API for build...
silverstripe/errorpage                           1.1.2                                         ErrorPage component for S...
silverstripe/framework                           4.1.2                                         The SilverStripe framework
silverstripe/graphql                             1.1.2                                         GraphQL server for Silver...
silverstripe/gridfieldqueuedexport               dev-feature/email_generated_csv 7ca6580       Export large data sets fr...
silverstripe/lumberjack                          2.0.1                                         A module to make managing...
silverstripe/raygun                              2.1.0                                         RayGun.io integration for...
silverstripe/recipe-cms                          1.1.2                                         SilverStripe recipe for f...
silverstripe/recipe-core                         1.1.2                                         SilverStripe framework-on...
silverstripe/recipe-plugin                       1.3.0                                         Helper plugin to install ...
silverstripe/redirectedurls                      dev-master 042ece4                            Provides a system for use...
silverstripe/reports                             4.1.2                                         Reports module for Silver...
silverstripe/segment-field                       2.2.1                                         A reusable approach to se...
silverstripe/siteconfig                          4.1.2                                         Site wide settings admini...
silverstripe/tagfield                            2.1.0                                         Tag field for Silverstripe
silverstripe/taxonomy                            2.0.1                                         Provide extra taxonomy fo...
silverstripe/userforms                           dev-feature/ConditionalRequiredFields 1c1c64c UserForms enables CMS use...
silverstripe/vendor-plugin                       1.3.3                                         Allows vendor modules to ...
silverstripe/versioned                           1.1.2                                         SilverStripe Versioned co...
squizlabs/php_codesniffer                        3.3.2                                         PHP_CodeSniffer tokenizes...
swiftmailer/swiftmailer                          v5.4.12                                       Swiftmailer, free feature...
symbiote/silverstripe-gridfieldextensions        3.2.0                                         A collection of useful gr...
symbiote/silverstripe-queuedjobs                 4.2.3                                         A framework for defining ...
symfony/browser-kit                              v3.4.17                                       Symfony BrowserKit Component
symfony/cache                                    v3.4.17                                       Symfony Cache component w...
symfony/config                                   v3.4.17                                       Symfony Config Component
symfony/console                                  v3.4.17                                       Symfony Console Component
symfony/css-selector                             v3.4.17                                       Symfony CssSelector Compo...
symfony/debug                                    v3.4.17                                       Symfony Debug Component
symfony/dom-crawler                              v3.4.17                                       Symfony DomCrawler Component
symfony/event-dispatcher                         v3.4.17                                       Symfony EventDispatcher C...
symfony/filesystem                               v3.4.17                                       Symfony Filesystem Component
symfony/finder                                   v3.4.17                                       Symfony Finder Component
symfony/options-resolver                         v3.4.17                                       Symfony OptionsResolver C...
symfony/polyfill-apcu                            v1.9.0                                        Symfony polyfill backport...
symfony/polyfill-ctype                           v1.9.0                                        Symfony polyfill for ctyp...
symfony/polyfill-mbstring                        v1.9.0                                        Symfony polyfill for the ...
symfony/polyfill-php56                           v1.9.0                                        Symfony polyfill backport...
symfony/polyfill-php70                           v1.9.0                                        Symfony polyfill backport...
symfony/polyfill-php72                           v1.9.0                                        Symfony polyfill backport...
symfony/polyfill-util                            v1.9.0                                        Symfony utilities for por...
symfony/process                                  v3.4.17                                       Symfony Process Component
symfony/stopwatch                                v3.4.17                                       Symfony Stopwatch Component
symfony/translation                              v2.8.46                                       Symfony Translation Compo...
symfony/var-dumper                               v3.4.17                                       Symfony mechanism for exp...
symfony/yaml                                     v3.4.17                                       Symfony Yaml Component
tractorcow/classproxy                            0.1.2                                        
tractorcow/silverstripe-proxy-db                 0.1.0                                        
webonyx/graphql-php                              v0.8.0                                        A PHP port of GraphQL ref...
wilr/silverstripe-googlesitemaps                 2.0.0                                         SilverStripe support for ...

@brynwhyman
Copy link

I'm seeing this in the new CWP demo which really isn't nice. I'm getting this in line for the upcoming sprint

@robbieaverill robbieaverill removed their assignment Feb 25, 2019
@brynwhyman brynwhyman added this to the Sprint 32 milestone Mar 5, 2019
@NightJar NightJar self-assigned this Mar 13, 2019
@NightJar
Copy link
Contributor

Problem goes away when:
image
Blocking GridFieldBulkEditingTools main.js

@NightJar
Copy link
Contributor

🤔
Load e.g. a UserDefinedForm page.
Hard refresh.
Do not see the issue.
Browse between pages using the site tree.
Do not see the issue.
Browse to UserDefinedForm page.
Do not see the issue.

Load a normal Page.
Hard refresh.
Do not see the issue.
Browse to UserDefinedForm
See the issue.

I notice that the javascript file identified above loads via an XHR rather than as a JS file (i.e. filtering on each type in the dev tools). I would assume that this confirms it is loaded via the CMS on-demand directive, rather than as an in-content <script> or such in the preview iframe.

@NightJar
Copy link
Contributor

NightJar commented Mar 17, 2019

Indeed, the parse error still occurs when the preview pane is shut.
I also notice that the timestamp (main.js?_=TIMESTAMP) is different every single time the file is requested. Perhaps this is a PHP fixable issue to do with the generation of that, and that the script within the file is not protected from itself.

image

Also interesting that this is an underscore and a timestamp. All CMS provided includes use an m rather than _ e.g. m=1234567

@NightJar
Copy link
Contributor

Also interesting that this is an underscore and a timestamp. All CMS provided includes use an m rather than _ e.g. m=1234567

This is our jquery.ondemand "thirdparty" script (that we wrote).
Requests for JS are made with dataType: 'script'
http://api.jquery.com/jQuery.ajax/

"script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, _=[TIMESTAMP], to the URL unless the cache option is set to true. Note: This will turn POSTs into GETs for remote-domain requests.

Also interesting in that script is that the whitelist option for that script is actually a blacklist in that they are the only GET query parameters to be stripped. Which was a fix introduced for silverstripe/silverstripe-framework#8346 - How long has this problem been happening for I wonder? This seems like it might be a red herring...

@NightJar
Copy link
Contributor

At this point I suspect one of two things:

  • silverstripe/silverstripe-admin@9a89aad fix instead moved the problem from affecting only multi server environments to affecting only single server environments. However this doesn't seem all that likely, as the script is mostly unchanged over time, and used to work fine (warning: assumption).
  • The context of self._ondemand_loaded_list in jquery.ondemand is not persistent enough to maintain track of dynamically loaded scripts (i.e. the ondemand ones). This is exampled by a direct load (hard refresh) not manifesting the issue, as the Requirements call will be in the first load returned HTML, rather than an in-memory script.

@NightJar
Copy link
Contributor

NightJar commented Mar 18, 2019

Probably should have just started here really :/

Error: Cannot mutate DI container after it has been initialised

image

Also stops any other ondemand script in the queue from being loaded.

It's Injector having a 'mare
JS related fix. Just need to find out what exactly now.

@NightJar
Copy link
Contributor

https://github.com/colymba/GridFieldBulkEditingTools/blob/master/client/src/js/uploader.js#L57

Injector is asked to make a transformation after it's instantiated.
Injector works by first having all bundles load and register their components and transformations, then instantiates (e.g. on page ready, rather than when loaded, if that helps convey the idea).

Along comes ondemand and loads transformations long after Injector is "ready".

@NightJar
Copy link
Contributor

@Cheddam recommends that perhaps the strategy needs to happen here. The bulk editing JS will need to load always (LeftAndMain.requirements_extra_js or something) and boot itself based on the presence of something to trigger it (e.g. via entwine still perhaps).

Or we go about making some hefty changes to Injector to allow it to accept components and/or transformations after it boots. Which seems... complicated.

@NightJar
Copy link
Contributor

"parsererror" should be resolved on an update :)
silverstripe/silverstripe-framework#8228 (comment)

However that doesn't solve the underlying cause, which will also see that bulk editing grid field items do not work.

@robbieaverill
Copy link
Contributor Author

To be honest, that sounds like a separate issue to me. We can review that module's JavaScript during the stabilisation work which still needs to be completed. Note that the module is still in beta phase.

Related issues: silverstripe/silverstripe-gridfield-bulk-editing-tools#176 silverstripe/silverstripe-gridfield-bulk-editing-tools#188

@NightJar
Copy link
Contributor

NightJar commented Mar 19, 2019

Indeed, this particular issue is done.

The fix is present in silverstripe/admin 1.3.2 onwards
Which is available in CWP 2.2.2 onwards.

@brynwhyman
Copy link

I've come across this again in a UAT version of the CWP demo, running CWP 2.3.rc1 (which I would have assumed included the latest version of admin).

Given this site is running a RC and is a UAT environment. I won't reopen the issue just yet - but I suspect I may have to soon...

Also, I'm not seeing any console errors with the parse error. It can be recreated by simply adding a new page.

@brynwhyman
Copy link

Thankfully, there was an issue with the UAT environment above. This can no longer be recreated.

Ignore my comment above :)

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

No branches or pull requests

7 participants