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

Unclosed regex pattern at position: 4715 #135

Open
CalzaFino opened this issue Jun 20, 2023 · 10 comments
Open

Unclosed regex pattern at position: 4715 #135

CalzaFino opened this issue Jun 20, 2023 · 10 comments

Comments

@CalzaFino
Copy link

CalzaFino commented Jun 20, 2023

Just updated to the newest version (1.6.7) and I am getting errors during static content deployment.

The Magento 2.4.6-p1 store with php 8.1 is showing the error:

Error happened during deploy process: Unclosed regex pattern at position: 4715

@emirajbbd
Copy link

RuntimeException: Unclosed regex pattern at position: 4543 in /vendor/tedivm/jshrink/src/JShrink/Minifier.php:639

Downgrading tedivm/jshrink (v1.6.7 => v1.6.6) fixed the issue

@eBusinessAtlantique
Copy link

eBusinessAtlantique commented Jun 20, 2023

Thanks for the hint @emirajbbd
It happens to me too. That is a shame that a small module from Magento 2 can stop the whole Magento. I understand people saying that Magento is heavy and unstable...

@boseasha
Copy link

@emirajbbd Downgrading to v1.6.6 doesnot fix the issue. I am having 2.4.6 version in PHP 8.2 in production mode with minify js enabled See error
RuntimeException: Unclosed regex pattern at position: 169201 in vendor/tedivm/jshrink/src/JShrink/Minifier.php:639

@tedivm
Copy link
Member

tedivm commented Jun 20, 2023

I've reverted the release- 1.6.8 matches 1.6.6.

If possible can someone share the code that actually triggered the bug?

@eBusinessAtlantique
Copy link

My log :
#34 {main} {"exception":"[object] (RuntimeException(code: 0): Unclosed regex pattern at position: 755 at /home/XXX.fr/public_html/vendor/tedivm/jshrink/src/JShrink/Minifier.php:639)"} []

@tedivm
Copy link
Member

tedivm commented Jun 20, 2023

The logs don't really help- what I need is the code that's being run through the minifier, so I can replicate the issue.

@eBusinessAtlantique
Copy link

I don't have that, this is the compiler of Magento 2 that sent this error.

@xaevik
Copy link

xaevik commented Jun 20, 2023

@tedivm @eBusinessAtlantique downgrading to 1.6.6 or upgrading to 1.6.8 does resolve issue with Magento 2 JS minification (we just ran into this).

@hostep
Copy link

hostep commented Jun 20, 2023

@tedivm: with version 1.6.7 we get a lot of failures on a lot of javascript files in the Magento code base.

One of them (in case it helps) is this one: https://raw.githubusercontent.com/magento/magento2/2.4.6-p1/app/code/Magento/Catalog/view/base/web/js/price-utils.js

Quick test locally after downloading that price-utils.js file:

<?php

require_once('vendor/autoload.php');

\JShrink\Minifier::minify(
    file_get_contents('/path/to/price-utils.js')
);

Running this results in:

PHP Fatal error:  Uncaught RuntimeException: Unclosed regex pattern at position: 4894 in JShrink/src/JShrink/Minifier.php:639
Stack trace:
#0 JShrink/src/JShrink/Minifier.php(298): JShrink\Minifier->saveRegex()
#1 JShrink/src/JShrink/Minifier.php(162): JShrink\Minifier->loop()
#2 JShrink/src/JShrink/Minifier.php(137): JShrink\Minifier->minifyToString('/**\n * Copyrigh...', Array)
#3 JShrink/test.php(5): JShrink\Minifier::minify('/**\n * Copyrigh...')
#4 {main}
  thrown in JShrink/src/JShrink/Minifier.php on line 639

Update: if you need more examples that fail:

@JDavidVR
Copy link

JDavidVR commented Feb 3, 2024

facing same issue when adding Alpine.js ( i get the file from: https://unpkg.com/[email protected]/dist/cdn.min.js )

it has issues with this section:

{message:"No error message given."},{el:t,expression:r}),console.warn(`Alpine Expression Error: ${e.message}

${r?'Expression: "'+r+`"

`:""}`,t),setTimeout(()=>{throw e},0)}var Ie=!0;function ke(e)

a them fix for me, was to change it to:

{message:"No error message given."},{el:t,expression:r}),console.warn(`Alpine Expression Error: ${e.message}

${r?'Expression: "'+r+`"`:""}`,t),setTimeout(()=>{throw e},0)}var Ie=!0;function ke(e)

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

No branches or pull requests

8 participants