Giter Site home page Giter Site logo

Problem with long pages about hexo-browsersync HOT 22 OPEN

hexojs avatar hexojs commented on August 23, 2024
Problem with long pages

from hexo-browsersync.

Comments (22)

coder-linx avatar coder-linx commented on August 23, 2024 5

This problem is caused by hexo-server, _config.yml add settings

server:
  compress: true

from hexo-browsersync.

tcrowe avatar tcrowe commented on August 23, 2024 1

I don't know if this is the same bug but I did get a very weird problem with a large post.

screen shot 2017-12-05 at 9 26 55 am

As you can see in the image it had intermittent blank spots. There was no error from hexo or the browser when this happened.

This is how I tried to reproduce your bug:

# create the project
mkdir hexo-bsync-big-text
cd hexo-bsync-big-text
hexo init

# generate some random text for the posts
# the issue reports anything around 1000 words
npm install chance-cli -g
hexo new post "one"
hexo new post "two"
hexo new post "three"

paragraph_count=100

for (( i = 0; i < $paragraph_count; i++ )); do
  chance paragraph >> source/_posts/one.md
  echo '\n\n' >> source/_posts/one.md
done

for (( i = 0; i < $paragraph_count; i++ )); do
  chance paragraph >> source/_posts/two.md
  echo '\n\n' >> source/_posts/two.md
done

for (( i = 0; i < $paragraph_count; i++ )); do
  chance paragraph >> source/_posts/three.md
  echo '\n\n' >> source/_posts/three.md
done

npm install
npm install hexo-browsersync --save
# it installed [email protected]

hexo serve --debug

On a hunch I tried commenting out the Stylus code and the page started to render all the text again. I'm using landscape theme in my demo.

Which theme are you using @giuem ?

from hexo-browsersync.

arsenicoco avatar arsenicoco commented on August 23, 2024 1

I am having the same issue with this theme (although slightly modified): typing. I don't think it has to deal with the theme itself. The only thing I see in the console is this:

WebSocket connection to 'ws://localhost:3000/browser-sync/socket.io/?EIO=3&transport=websocket&sid=GGauSBElfMuLBbrVAAAE' failed: WebSocket is closed due to suspension.

I assume this could be well the reason for dropping rendering at an almost random point.

from hexo-browsersync.

giuem avatar giuem commented on August 23, 2024

I meet the same problem. And it seems that this problem is related to theme, I'm trying to find the answer...

from hexo-browsersync.

xsfishxs avatar xsfishxs commented on August 23, 2024

+1 Meet the same problem. Seems like a problem caused by the buffer size.

from hexo-browsersync.

tcrowe avatar tcrowe commented on August 23, 2024

Is this still a problem? We recently updated the module too.

from hexo-browsersync.

giuem avatar giuem commented on August 23, 2024

@tcrowe Problem still remains. Can you reproduce this bug?

from hexo-browsersync.

giuem avatar giuem commented on August 23, 2024

I'm using this theme. And I have try your demo with this theme, the bug doesn't reproduce. Maybe this bug is related to post content?

The bug looks like this, html code was cut off.
snipaste_2017-12-06_12-15-41

snipaste_2017-12-06_12-17-46

from hexo-browsersync.

tcrowe avatar tcrowe commented on August 23, 2024

I tried it again with your theme (very nice!) but I did not reproduce the error.

If you would please try a few things:

Somewhere around here:
https://github.com/hexojs/hexo-browsersync/blob/master/lib/browsersync.js#L31

Add:

console.log('op', op)
console.log('pos', pos)
console.log('snippet', snippet)

Lets see what the output is.

Another thing you can try is upgrade all modules:

# upgrade hexo and get module updater
npm install npm-check-updates hexo@latest -g

# in your project, updates versions
ncu -an 
npm install

# clean
rm db.json debug.log

hexo serve --debug

You can also tell us npm ls --depth=0 which can show us other plugins that may modify source

Thank you!

from hexo-browsersync.

kyya avatar kyya commented on August 23, 2024

The same problem, may be the error is here.
sometimes the pos of </body> may has wrong value.

from hexo-browsersync.

tcrowe avatar tcrowe commented on August 23, 2024

Do you know how to get a failing test case for this, @anapopo ? We could not reproduce the error.

from hexo-browsersync.

fatfatson avatar fatfatson commented on August 23, 2024
pos 138 
op <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot GET /es6-promise.map</pre> </body> </html> 
snippet <script id="__bs_script__">//<![CDATA[ document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.js?v=2.24.6'><\/script>".replace("HOST", location.hostname)); //]]></script>

it's very strange, every time the log shows a error repsonse, but the browser show the page ok

from hexo-browsersync.

fatfatson avatar fatfatson commented on August 23, 2024
  function converter(content, req, res, callback) {
    var op = content.toString('utf8');
    var pos = op.lastIndexOf('</body>');

    //console.log('op', op)
    console.log('op last', op.substring(op.length-3000))
    console.log('op length', op.length)
    console.log('pos', pos, )
    return callback(null,op);

    if (!~pos) {
      return callback(null, content);
    }

    // op = op.substring(0, pos) + snippet + op.substring(pos);
    callback(null, op);
  }

i don't know why here the op is already truncated,
even the plugin does nothing, the result is wrong.
but if commenting the the app.use(...), then result is correct...

from hexo-browsersync.

fatfatson avatar fatfatson commented on August 23, 2024

OK, I think I have found the problem!
it's in connect-injector:

      write: function (chunk, encoding) {
        if (this._interceptCheck()) {
          if(!this._interceptBuffer) {
            debug('initializing _interceptBuffer');
            this._interceptBuffer = new WritableStream();
          }

            debug('write', new Buffer(chunk,encoding).length);
            return this._interceptBuffer.write(new Buffer(chunk,encoding));
          //return this._interceptBuffer.write(chunk, encoding);
        }

it redirects res.write to its own WritableStream, but fails to provide a suitable encoding, (here is undeinfed, but it should be utf8), so data with none-ascii would be lost.
replace the write with Buffer solves it.

from hexo-browsersync.

tcrowe avatar tcrowe commented on August 23, 2024

@fatfatson 🤔

That's interesting you may have found a solution after all this time. We could not reproduce it. Were you able to? If so, how?

from hexo-browsersync.

fatfatson avatar fatfatson commented on August 23, 2024

@tcrowe making a long post( >130K in my case) with chinese would reproduce it

from hexo-browsersync.

yuki-takei avatar yuki-takei commented on August 23, 2024

@tcrowe

@fatfatson is right. This problem has been reproduced with hexo-browsersync:0.3.0.
Have you ever tested with CJK(Chinese/Japanese/Korean) strings?

How to reproduce

  1. Install browser-sync:0.3.0
  2. Copy japanese lolem ipsum from here
  3. Create test.md and paste lolem ipsum 10 times. It should be over 13000 characters.
  4. hexo serve and go to /test.html

What happens?

  • Hexo will not render the whole contents.
    • Only 8000 characters were rendered in my environment.
    • The partial of footer (if you devide it) will not be rendered.

What is the expected result?

  • The whole contents are rendered.

from hexo-browsersync.

tcrowe avatar tcrowe commented on August 23, 2024

@yuki-takei Thank you! I wont be able to look at it for a few days but I will review this and test again soon. 👍

from hexo-browsersync.

YunYouJun avatar YunYouJun commented on August 23, 2024

I meet the same problem.
May I know the progress about this problem?
Or any temporary methods to solve it?

from hexo-browsersync.

YunYouJun avatar YunYouJun commented on August 23, 2024

This problem is caused by hexo-server, _config.yml add settings

server:
  compress: true

Cool, it works. Thanks!

from hexo-browsersync.

Chorer avatar Chorer commented on August 23, 2024

same problem.It has remain for a long time.And I found it happends only when hexo s.

from hexo-browsersync.

seed42x avatar seed42x commented on August 23, 2024

Same problem

from hexo-browsersync.

Related Issues (19)

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.