You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/03 02:18:37 UTC

[GitHub] [airflow] bbovenzi opened a new pull request, #24152: Fix useTasks crash on error

bbovenzi opened a new pull request, #24152:
URL: https://github.com/apache/airflow/pull/24152

   Prevent the UI from crashing if get API endpoints fail. Use `initialData` for get requests, which will persist even with an error. But then make sure the initialData is stale by default with `initialDataUpdatedAt` of 6 minutes ago. (https://tkdodo.eu/blog/placeholder-and-initial-data-in-react-query)
   
   For `useMappedInstances`, we do need a different staleTime to make sure it stays fresh even after auto-refresh. (Trigger a dag run -> look at a mapped task -> look at a different task -> wait for dag to finish -> go back to mapped task and see that all mapped instances are also finished)
   
   Prevent some re-renders with : `notifyOnChangeProps: 'tracked',` (https://tkdodo.eu/blog/placeholder-and-initial-data-in-react-query)
   
   Related: https://github.com/apache/airflow/issues/23588
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragement file, named `{pr_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi merged pull request #24152: Fix useTasks crash on error

Posted by GitBox <gi...@apache.org>.
bbovenzi merged PR #24152:
URL: https://github.com/apache/airflow/pull/24152


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] github-actions[bot] commented on pull request #24152: Fix useTasks crash on error

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #24152:
URL: https://github.com/apache/airflow/pull/24152#issuecomment-1146360131

   The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #24152: Fix useTasks crash on error

Posted by GitBox <gi...@apache.org>.
bbovenzi commented on code in PR #24152:
URL: https://github.com/apache/airflow/pull/24152#discussion_r889388270


##########
airflow/www/jest-setup.js:
##########
@@ -20,6 +20,21 @@
  */
 
 import '@testing-library/jest-dom';
+import axios from 'axios';
+import { setLogger } from 'react-query';
+
+axios.defaults.adapter = require('axios/lib/adapters/http');
+
+axios.interceptors.response.use(
+  (res) => res.data || res,
+);
+
+setLogger({
+  log: console.log,
+  warn: console.warn,
+  // ✅ no more errors on the console

Review Comment:
   This is just for tests. We are intentionally creating API errors. So it doesn't need to be logged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] jedcunningham commented on a diff in pull request #24152: Fix useTasks crash on error

Posted by GitBox <gi...@apache.org>.
jedcunningham commented on code in PR #24152:
URL: https://github.com/apache/airflow/pull/24152#discussion_r889347084


##########
airflow/www/jest-setup.js:
##########
@@ -20,6 +20,21 @@
  */
 
 import '@testing-library/jest-dom';
+import axios from 'axios';
+import { setLogger } from 'react-query';
+
+axios.defaults.adapter = require('axios/lib/adapters/http');
+
+axios.interceptors.response.use(
+  (res) => res.data || res,
+);
+
+setLogger({
+  log: console.log,
+  warn: console.warn,
+  // ✅ no more errors on the console

Review Comment:
   Maybe a silly question, if they don't end up on the console, where do they end up?



##########
airflow/www/static/js/grid/index.jsx:
##########
@@ -42,14 +42,19 @@ const myCache = createCache({
 const mainElement = document.getElementById('react-container');
 shadowRoot.appendChild(mainElement);
 
+const now = new Date();
+const minAgo = now.setMinutes(now.getMinutes() - 6);
+
 const queryClient = new QueryClient({
   defaultOptions: {
     queries: {
+      notifyOnChangeProps: 'tracked',
       refetchOnWindowFocus: false,
       retry: 1,
       retryDelay: 500,
-      staleTime: 5 * 60 * 1000, // 5 minutes
       refetchOnMount: true, // Refetches stale queries, not "always"
+      staleTime: 5 * 60 * 1000, // 5 minutes
+      initialDataUpdatedAt: minAgo, // make sure initial data is already expired

Review Comment:
   I think this also works, and makes it a little simpler:
   ```suggestion
         initialDataUpdatedAt: new Date().setMinutes(-6), // make sure initial data is already expired
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org