Skip to content

snapshot not load after refresh [$5] #3388

@withinthefog

Description

@withinthefog

Refresh page in nwjs 0.12.1 will Cause the snapshot to fail.

Here is the code to reproduce the Scenario:

package.json:

{
  "name": "nw-refresh",
  "main": "index.html"
}

index.html:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<script src="app.js"></script>

</body>
</html>

app.js:

require('nw.gui').Window.get().evalNWBin(null, 'snapshot.bin');
var lib = require('./lib');

try {
    console.log('calling snapshot function from web...');
    echoInSnapshot();
} catch (e) {
    console.error('error calling snapshot function:', e.stack)
}

lib.callSnapshot();

lib.js:

exports.callSnapshot = function () {
    try {
        console.log('calling snapshot function from node...');
        echoInSnapshot();
    } catch (e) {
        console.error('call snapshot from node error:', e.stack);
    }
};

snapshot.js:

function echoInSnapshot() {
    console.log('in snapshot function')
}

Compile the snapshot.js using the command:

nwjc snapshot.js snapshot.bin

Start the nw.app, the log from app.js is collect, but if I hit the refresh(or refreshDev) button, there will be a RefrenceError says echoInSnapshot is not defined.

Also, calling snapshot functions from node context(like the code in lib.js above) will cause a RefrenceError echoInSnapshot is not defined. But in previous version(0.11.x), the functions in snapshot can be called Directly from a node context.

Did you help close this issue? Go claim the $5 bounty on Bountysource.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions