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

Live reload causes blueprint to not render correctly #239

Open
kennydude opened this issue Mar 2, 2016 · 3 comments · May be fixed by #325
Open

Live reload causes blueprint to not render correctly #239

kennydude opened this issue Mar 2, 2016 · 3 comments · May be fixed by #325

Comments

@kennydude
Copy link

When using Live-reload aglio will sometimes render an entirely blank version of my blueprint. The only way to fix this is to stop and restart the command and it works correctly.

This is using aglio 2.2 and nodejs 2.5.0

@jdpnielsen
Copy link

What is your setup?

I have a working gulp task, setup somewhat like this:

'use strict';

var gulp = require('gulp');
var aglio = require('aglio');
var browserSync = require('browser-sync');

var config = require('../config');
var logger = require('../../lib/logger');

gulp.task('docs', function() {
    var options = {
        themeVariables: 'slate',
        themeTemplate: 'triple',
    };

    aglio.renderFile(config.input, config.output, options, function(err, html, warnings) {
        if (err) {
            return logger.error('Error while rendering blueprint:', err);
        }
        if (warnings) {
            logger.warn('Warning while rendering blueprint:', warnings);
        }

        if (browserSync.active) {
            browserSync.reload();
        }
    });
});

gulp.task('watch', ['browserSync', 'server'], function() {
    gulp.watch(config.input, ['docs']);
});

@kennydude
Copy link
Author

I just run it like so aglio -s -i docs.apib

@leclairmael
Copy link

I am currently experiencing the same issue as @kennydude on ArchLinux with aglio 2.3.0

After digging for a while, I realized that the length of the blueprint document being read was often 0, so I suspected there was a race condition happening while the file was being read.
The documentation of chokidar confirmed my suspicion, explaining things clearly:
By default, the add event will fire when a file first appear on disk, before the entire file has been written. Furthermore, in some cases some change events will be emitted while the file is being written. In some cases, especially when watching for large files there will be a need to wait for the write operation to finish before responding to a file creation or modification.

I will post a pull request shortly.

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

Successfully merging a pull request may close this issue.

3 participants