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

"max buffer exceeded" error #13

Closed
kokizzu opened this issue Mar 9, 2015 · 5 comments
Closed

"max buffer exceeded" error #13

kokizzu opened this issue Mar 9, 2015 · 5 comments

Comments

@kokizzu
Copy link

kokizzu commented Mar 9, 2015

I got them while minifying:
AceJS: https://github.com/ajaxorg/ace-builds/blob/master/src/ace.js 615.6 KiB (630,413 bytes)
and jquery.dataTables.js: http://datatables.net/download/ 424.8 KiB (434,957 bytes)
any solution for this case?

@kokizzu
Copy link
Author

kokizzu commented Mar 9, 2015

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(';')
}

@tdewolff
Copy link
Owner

tdewolff commented Mar 9, 2015

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

@kokizzu
Copy link
Author

kokizzu commented Mar 9, 2015

Yes, the error still the same..

@kokizzu
Copy link
Author

kokizzu commented Mar 9, 2015

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

@tdewolff
Copy link
Owner

tdewolff commented Mar 9, 2015

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.

@tdewolff tdewolff closed this as completed Mar 9, 2015
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

2 participants