Skip to content

Commit

Permalink
Fix recursion in sync routine. (#13818)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad authored and youknowriad committed Feb 12, 2019
1 parent 0c30ee3 commit 134214d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/redux-routine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

- Fix unhandled promise rejection error caused by returning null from registered generator ([#13314](https://github.com/WordPress/gutenberg/pull/13314))
- The middleware will no longer attempt to coerce an error to an instance of `Error`, and instead passes through the thrown value directly. This resolves issues where an `Error` would be thrown when the underlying values were not of type `Error` or `string` (e.g. a thrown object) and the message would end up not being useful (e.g. `[Object object]`).
([#13315](https://github.com/WordPress/gutenberg/pull/13315))
([#13315](https://github.com/WordPress/gutenberg/pull/13315))
- Fix unintended recursion when invoking sync routine ([#13818](https://github.com/WordPress/gutenberg/pull/13818))

## 3.0.3 (2018-10-19)

Expand Down
2 changes: 1 addition & 1 deletion packages/redux-routine/src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function createRuntime( controls = {}, dispatch ) {
// Async control routine awaits resolution.
routine.then( yieldNext, yieldError );
} else {
next( routine );
yieldNext( routine );
}
return true;
} );
Expand Down
17 changes: 17 additions & 0 deletions packages/redux-routine/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,21 @@ describe( 'createMiddleware', () => {

expect( store.getState() ).toBe( 2 );
} );

it( 'does not recurse when action like object returns from a sync ' +
'control', () => {
const post = { type: 'post' };
const middleware = createMiddleware( {
UPDATE: () => post,
} );
const store = createStoreWithMiddleware( middleware );
function* getPostAction() {
const nextState = yield { type: 'UPDATE' };
return { type: 'CHANGE', nextState };
}

store.dispatch( getPostAction() );

expect( store.getState() ).toEqual( post );
} );
} );

0 comments on commit 134214d

Please sign in to comment.