Giter Site home page Giter Site logo

"max buffer exceeded" error about minify HOT 5 CLOSED

tdewolff avatar tdewolff commented on May 14, 2024
"max buffer exceeded" error

from minify.

Comments (5)

kokizzu avatar kokizzu commented on May 14, 2024

The code:

js := bytes.Buffer{}
dat, err := ioutil.ReadFile(fname)
if L.Check(err, `File doesn't exists: `+fname) == nil {
  dat, err = min.MinifyBytes(`text/js`, dat)
  js.Write(dat) 
  js.WriteRune(';')
}

from minify.

tdewolff avatar tdewolff commented on May 14, 2024

I cannot reproduce, are you sure you update tdewolff/parse lately for I pushed tdewolff/parse@9e980e5 with a bugfix.

from minify.

kokizzu avatar kokizzu commented on May 14, 2024

Yes, the error still the same..

from minify.

kokizzu avatar kokizzu commented on May 14, 2024

minimum code to reproduce:

package main

import `fmt`
import `io/ioutil`
import `github.com/tdewolff/minify`
import `github.com/tdewolff/minify/js`

func main() {
    min := minify.NewMinifier()
    min.Add("text/js", js.Minify)
    fname := `/tmp/ace.js`
    dat, err := ioutil.ReadFile(fname)
    if err == nil {
        dat, err = min.MinifyBytes(`text/js`, dat)
        if err == nil {
            fmt.Println(`ok`)
        } else {
            fmt.Printf("%# v\n", err)
        }
    } else {
        fmt.Printf("%# v\n", err)
    }
}

output:

&errors.errorString{s:"max buffer exceeded"}

ace.js downloaded from https://raw.githubusercontent.com/ajaxorg/ace-builds/master/src/ace.js

from minify.

tdewolff avatar tdewolff commented on May 14, 2024

The problem is that ace.js contains a very very long string which exceeds the maximum buffer limit. This limit is set to 4096 bytes in https://github.com/tdewolff/parse/blob/master/shiftbuffer.go#L10

But the string is 11508 characters long, I drastically increased the limit, but one can do this manually too. tdewolff/parse@dd3690f

Additionally, this is fixed by 69eb7cf by using the provided slice which sets no size limit.

from minify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.