<commit_before>var React = require('react');
var ReactDOM = require('react-dom');
var ReactServer = require('react-dom/server');
var AppSession = require('./session/AppSession');
var MyApp = require('./components/MyApp');
var AppActions = require('./actions/AppActions');
var redux = require('redux');
var AppReducer = require('./reducers/AppReducer');
var cE = React.createElement;

var main = exports.main = function(data) {
    var ctx =  {store: redux.createStore(AppReducer)};
    if (typeof window === 'undefined') {
        // server side rendering
        AppActions.initServer(ctx, data);
        return ReactServer.renderToString(cE(MyApp, {ctx: ctx}));
    } else {
        return (async function() {
            try {
                await AppSession.connect(ctx);
                ReactDOM.render(cE(MyApp, {ctx: ctx}),
                                document.getElementById('content'));
            } catch (err) {
                console.log('Cannot connect:' + err);
            }
        })();
    }
};<commit_msg>Display session errors<commit_after>var React = require('react');
var ReactDOM = require('react-dom');
var ReactServer = require('react-dom/server');
var AppSession = require('./session/AppSession');
var MyApp = require('./components/MyApp');
var AppActions = require('./actions/AppActions');
var redux = require('redux');
var AppReducer = require('./reducers/AppReducer');
var cE = React.createElement;

var main = exports.main = function(data) {
    var ctx =  {store: redux.createStore(AppReducer)};
    if (typeof window === 'undefined') {
        // server side rendering
        AppActions.initServer(ctx, data);
        return ReactServer.renderToString(cE(MyApp, {ctx: ctx}));
    } else {
        return (async function() {
            try {
                await AppSession.connect(ctx);
                ReactDOM.render(cE(MyApp, {ctx: ctx}),
                                document.getElementById('content'));
            } catch (err) {
                document.getElementById('content').innerHTML =
                    '<H1>Cannot connect: ' + err + '<H1/>';
                console.log('Cannot connect:' + err);
            }
        })();
    }
};
{'fraction_non_alphanumeric': 0.15132178669097537, 'fraction_numerical': 0.0009115770282588879, 'mean_word_length': 2.4786053882725834, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4691951', 'n_tokens_mistral': 607, 'n_tokens_neox': 593, 'n_words': 135}