Grails

Flash scope is unsafe as it does not know which request / flow the flash relates to

Details

  • Type: Sub-task Sub-task
  • Status: Open Open
  • Priority: Critical Critical
  • Resolution: Unresolved
  • Affects Version/s: 0.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

As flash is not bound to any kind of flow ID currently, the next request might be for another resource not part of the current flow, and hence wipe out the flash scope before the next (intended) page is retrieved.

This should be easy to fix once flows are implemented

Activity

Hide
David Smiley added a comment -

I'm not sure if this bug report is for what I'm seeing... but basically, I'm seeing the flash scope having values from the previous request even though it wasn't a redirect. AFAIK, flash should only retain its values from one request to the next if it is redirected. By keeping the values around, my code is confused and thinks it needs to re-display a message to the user.

Show
David Smiley added a comment - I'm not sure if this bug report is for what I'm seeing... but basically, I'm seeing the flash scope having values from the previous request even though it wasn't a redirect. AFAIK, flash should only retain its values from one request to the next if it is redirected. By keeping the values around, my code is confused and thinks it needs to re-display a message to the user.
Hide
Marc Palmer added a comment -

David - in Grails flash scope is always available, it doesn't matter how you go there.

However the above issue with flows exists I believe.

Show
Marc Palmer added a comment - David - in Grails flash scope is always available, it doesn't matter how you go there. However the above issue with flows exists I believe.
Hide
Graeme Rocher added a comment -

Moving non-critical issues that aren't going to make it into 1.1 to 1.2

Show
Graeme Rocher added a comment - Moving non-critical issues that aren't going to make it into 1.1 to 1.2
Hide
Ryan Zezeski added a comment -

I believe I'm encountering the same problem. I have two actions 1) show and 2) update. The 'show' action places a JSON structure in the Flash that the 'update' action relies on. Users were reporting intermittent NPE's when invoking the 'update' action. It turns out the problem is that there are multiple ExtJS tables on the same page that do asynchronous requests back to the same web-app. If the user clicks refresh on one of the tables, then that request wipes the JSON structure that was in the Flash, and then when the user invokes the update action a NPE occurs.

I plan to fix this by just putting the structure in the session, but I thought I'd confirm this issue.

Show
Ryan Zezeski added a comment - I believe I'm encountering the same problem. I have two actions 1) show and 2) update. The 'show' action places a JSON structure in the Flash that the 'update' action relies on. Users were reporting intermittent NPE's when invoking the 'update' action. It turns out the problem is that there are multiple ExtJS tables on the same page that do asynchronous requests back to the same web-app. If the user clicks refresh on one of the tables, then that request wipes the JSON structure that was in the Flash, and then when the user invokes the update action a NPE occurs. I plan to fix this by just putting the structure in the session, but I thought I'd confirm this issue.
Hide
Ueli Kistler added a comment -

Same problem using asynchronous calls as well, using just a single action.

Reproducing the problem:
1. A asynchronous call is triggered from the browser
2. flash scope is used and a message list is inserted (flash.messages)
3. Message is shown correctly
4. Another asynchronous call is triggered, same action
5. The list is still in the flash scope, containing the previous message as well!
6. Both messages are show (previous and current)
6. 3rd asynchronous call, same action
7. flash scope is empty again, then filled with a new message
8. .. and so on, it (somehow) consitently shows the current message then last & current and current message again

Tested in Firefox and Chrome, same behaviour.

Workaround:
Reset your flash scope variables at each request

Show
Ueli Kistler added a comment - Same problem using asynchronous calls as well, using just a single action. Reproducing the problem: 1. A asynchronous call is triggered from the browser 2. flash scope is used and a message list is inserted (flash.messages) 3. Message is shown correctly 4. Another asynchronous call is triggered, same action 5. The list is still in the flash scope, containing the previous message as well! 6. Both messages are show (previous and current) 6. 3rd asynchronous call, same action 7. flash scope is empty again, then filled with a new message 8. .. and so on, it (somehow) consitently shows the current message then last & current and current message again Tested in Firefox and Chrome, same behaviour. Workaround: Reset your flash scope variables at each request
Hide
Ueli Kistler added a comment -

This is actually expected when using flash scope ..
http://grails.org/doc/1.1.x/ref/Controllers/flash.html

Show
Ueli Kistler added a comment - This is actually expected when using flash scope .. http://grails.org/doc/1.1.x/ref/Controllers/flash.html
Hide
Marc Palmer added a comment -

Ueli I think you are misunderstanding the problem.

Flash scope is not bound to the current flow, so you can get pollution of flash between concurrent flows. This is a bug.

Show
Marc Palmer added a comment - Ueli I think you are misunderstanding the problem. Flash scope is not bound to the current flow, so you can get pollution of flash between concurrent flows. This is a bug.
Hide
Graeme Rocher added a comment -

There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3

for 1.2 final only issues considered blocking will now be fixed

Show
Graeme Rocher added a comment - There is no scope / time to resolve these remaining lower priority issues for 1.2 so moving to 1.3 for 1.2 final only issues considered blocking will now be fixed
Hide
Matthias Hryniszak added a comment -

Ueli, can you produce an example showing this problem and attach it to this bug?

Show
Matthias Hryniszak added a comment - Ueli, can you produce an example showing this problem and attach it to this bug?
Hide
Rick Jensen added a comment -

Given that this also has a rather large impact on REST-oriented applications that use REST JSON and/or XML responses to AJAX calls, it would make sense to address this for v2.2 with the proposed server-side REST improvements.

Show
Rick Jensen added a comment - Given that this also has a rather large impact on REST-oriented applications that use REST JSON and/or XML responses to AJAX calls, it would make sense to address this for v2.2 with the proposed server-side REST improvements.
Hide
Jeff Brown added a comment -

For the scenario where a webflow is putting something in flash scope that is relevant to that flow, that information should instead be put in flow scope, correct?

Show
Jeff Brown added a comment - For the scenario where a webflow is putting something in flash scope that is relevant to that flow, that information should instead be put in flow scope, correct?

People

Vote (7)
Watch (10)

Dates

  • Created:
    Updated:
    Last Reviewed: