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

feat: add initialImageMasking to mirror frog:image meta tag #268

Closed
wants to merge 2 commits into from

Conversation

dalechyn
Copy link
Collaborator

No description provided.

@dalechyn dalechyn self-assigned this Apr 18, 2024
Copy link

vercel bot commented Apr 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2024 5:56pm
frog-frame ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2024 5:56pm

Copy link

vercel bot commented Apr 18, 2024

@dalechyn is attempting to deploy a commit to the wevm Team on Vercel.

A member of the Team first needs to authorize it.

@madroneropaulo
Copy link

madroneropaulo commented Apr 18, 2024

I've some more context about this:
Basically cloudflare does NOT allow making fetch requests to workers of the same account https://community.cloudflare.com/t/get-error-code-1042-when-fetching-within-worker/288031/2 so there's no way to get the metadata with the image content in cloudflare workers. Thanks @dalechyn for helping me debugging it and for coming up with a quick workaround. This was a serious blocker for me.

Comment on lines +690 to 692
context.status === 'initial' && this.initialImageMasking
? `${context.url}/image`
: imageUrl
Copy link
Member

Choose a reason for hiding this comment

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

What was the motivation behind this behavior again? I wonder if we can avoid it altogether so we don't have to do these workarounds which don't function well in other environments.

Choose a reason for hiding this comment

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

As far as I understand by the code, and this PR the reason was to make the first frame dynamic. Say you have the frame:image metatag pointing to myFrame.com/image which is cached by warpcast. You can't put a static image in that route, so the dynamic image must be somewhere else so that when warpcast calls the /image path a function returns the image from the dynamic attribute in the meta tag. Btw I'm not sure this is not a bug from the warpcast team. the cache-control thing they did doesn't seem to work intuitively. Probably the best is reach out to them and find a clean solution.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What was the motivation behind this behavior again? I wonder if we can avoid it altogether so we don't have to do these workarounds which don't function well in other environments.

It was added to support refreshing of the first frame image.

There are basically two rules we have to comply to:

  • image response must have a Cache-Control header;
  • image url must be the same across "refreshes".

The latter was the focus, as before #222, the initial frame image url image always depended on the image itself (as it is compressed and put to query), which makes refreshing never possible.

frog:image was introduced to store the full url while fc:frame:image stays the same across updates.

@0xzoo
Copy link

0xzoo commented Apr 19, 2024

I've some more context about this: Basically cloudflare does NOT allow making fetch requests to workers of the same account https://community.cloudflare.com/t/get-error-code-1042-when-fetching-within-worker/288031/2 so there's no way to get the metadata with the image content in cloudflare workers. Thanks @dalechyn for helping me debugging it and for coming up with a quick workaround. This was a serious blocker for me.

seeing someone running on vercel edge having the same issue. not sure this is cloudflare related

@dalechyn
Copy link
Collaborator Author

I've some more context about this: Basically cloudflare does NOT allow making fetch requests to workers of the same account https://community.cloudflare.com/t/get-error-code-1042-when-fetching-within-worker/288031/2 so there's no way to get the metadata with the image content in cloudflare workers. Thanks @dalechyn for helping me debugging it and for coming up with a quick workaround. This was a serious blocker for me.

seeing someone running on vercel edge having the same issue. not sure this is cloudflare related

Thank you will check it with vercel template.

dalechyn added a commit to dalechyn/frog that referenced this pull request Apr 19, 2024
Previously, `frog:image` meta tag was used as a workaround that held the
full image URL which has an `image` query parameter that contains a
compressed serialized image itself.
However, initial frame image doesn't have `c.frameData`-based constraints
as it is not present on the initial render.

This change moves the initial image render responsibility to the `/image`
handler itself, removing the request from an `/image` route one level up
to get the full URL from `frog:image`, and removes this meta tag as
well.

Double request or a request within self has created issues with wrangler
deployments (that I tried to fix in wevm#268 by opting out from `frog:image`
tag and falling back to long initial frame image URL), and created
issues within Vercel Edge deployments that treat such a request as an
"Infinite" one.

Supersedes wevm#268.
@dalechyn
Copy link
Collaborator Author

Closing in favor of a general solution that drops frog:image meta tag.

#271.

@dalechyn dalechyn closed this Apr 19, 2024
dalechyn added a commit that referenced this pull request May 2, 2024
Previously, `frog:image` meta tag was used as a workaround that held the
full image URL which has an `image` query parameter that contains a
compressed serialized image itself.
However, initial frame image doesn't have `c.frameData`-based constraints
as it is not present on the initial render.

This change moves the initial image render responsibility to the `/image`
handler itself, removing the request from an `/image` route one level up
to get the full URL from `frog:image`, and removes this meta tag as
well.

Double request or a request within self has created issues with wrangler
deployments (that I tried to fix in #268 by opting out from `frog:image`
tag and falling back to long initial frame image URL), and created
issues within Vercel Edge deployments that treat such a request as an
"Infinite" one.

Supersedes #268.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants