Skip to content

Incorrect behavior when resolved with a promise, and later resolved (or rejected) again #2

Description

@meduzik

Consider the following code:

promise = Promise.new(function(resolve, reject)
	resolve(delayed_resolve(3, "from delayed"))
	resolve("from test")	
end)
promise:next(function(result)
	print(result)
end)

Where delayed_resolve returns a promise resolved with its second argument after specified delay.

From promise spec (and nodejs implementation), the correct behavior is to print from delayed after 3 seconds. But from test is printed immediately instead.

Similar NodeJS code:

function delay(time, val) {
	return new Promise(function (resolve, _) {
		setTimeout(function () {
			resolve(val);
		}, time * 1000);
	});
}

new Promise(function (resolve, reject) {
	resolve(delay(3, "from delay"));
	resolve("from test");
}).then(function (val) {
	console.log(val);
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions