Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] Re-enable wp-cron #2039

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ public function __destruct()
*/
public function request($url, $headers = array(), $data = array(), $options = array())
{
// Disable wp-cron requests that are extremely slow in node.js runtime environment.
// @TODO: Make wp-cron requests faster.
if (str_contains($url, '/wp-cron.php')) {
return false;
}

if (!empty($data)) {
$data_format = $options['data_format'];
if ($data_format === 'query') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function handleRequest(data: RequestData, fetchFn = fetch) {
const fetchHeaders = data.headers || {};

const hasContentTypeHeader = Object.keys(fetchHeaders).some(
(name) => name.toLowerCase() === "content-type"
(name) => name.toLowerCase() === 'content-type'
);

if (fetchMethod == 'POST' && !hasContentTypeHeader) {
Expand All @@ -84,7 +84,7 @@ export async function handleRequest(data: RequestData, fetchFn = fetch) {
response = await fetchFn(fetchUrl, {
method: fetchMethod,
headers: fetchHeaders,
body: data.data,
body: fetchMethod === 'GET' ? undefined : data.data,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tangential bugfix – I noticed some requests failed with "GET requests cannot have body" when data.data was an empty string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tangential bugfix – I noticed some requests failed with "GET requests cannot have body" when data.data was an empty string.

Nice.

credentials: 'omit',
});
} catch (e) {
Expand Down