Open marcelopbarros opened 9 months ago
@marcelopbarros :wave: Thanks for the report. I can't access the repo you've linked.
In any case, the most likely case for the error is a CORS error when trying to fetch that schema URL.
@marcelopbarros 👋 Thanks for the report. I can't access the repo you've linked.
To make things a little easier I created a new repo with a minimal viable example. This one is public:
https://github.com/marcelopbarros/schema-yaml-test
The warning still persists in StackBlitz (and it works locally).
But using this new repo I realized the schema still works, even with the warning. (In my personal project I had to disable and enable the YAML extension to make everything working again).
At the beginning I was assuming the reason the schema wasn't working it was because of the warning. But now, that I see things works even with the warning, I think you are free to judge if it still worth to look at the root of the socket hang up
problem (if it's really a CORS error). Feel free to close the issue if you think the warning is ok.
Thank you for your time (and apologies for any inconvenience 🙃)
It is indeed a network related problem. From your second screenshot, I don't think it is actually working. It should give you errors if, for instance, you don't have a label
, or you define it to be a numeric value.
If you change the schema URL to be https
, everything should work. This is a hard limitation of WebContainer: we can't magically bypass network restrictions from the browser i.e. mixing http and https content in certain contexts.
Can you confirm changing the URL works for you?
First, I tried testing without any changes, to confirm that the schema is being loaded even with the socket hang up
warning. As you commented, changing label
to a numeric value generates an error. So, I believe the schema is being loaded. The definition also appears at the bottom of the screen, next to the keyboard layout: pages
.
Also, as you suggested, changing the URL to https
gets rid of the warning:
Finally, it's worth mention that the YAML Extension has a "yaml.schemaStore.url"
config, which by default (according to this) points to "https://www.schemastore.org/api/json/catalog.json"
. This catalog seems to have some JSON Schema (all using https
). I believe that's the reason the validation still works even with the warning.
Describe the bug
When creating a YAML Schema usually we start with something like that in a _schema.json file:
But when writing on StackBlitz I got that error:
Unable to load schema from 'http://json-schema.org/draft-06/schema': socket hang up.
Link to the blitz that caused the error
https://stackblitz.com/~/github.com/marcelopbarros/mgmgoiania
Steps to reproduce
Open the file on
src/content/pages/_schema.json
that starts with"$schema": "http://json-schema.org/draft-06/schema#"
.Expected behavior
No errors or warnings
Parity with Local
Screenshots
Platform
Additional context
When using local the error doesn't appear. I believe the URL is somewhat blocked when running on StackBlitz.