Skip to content

add Promise/setTimeout/setInterval to GLOBALS_ALLOWED #13442

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zhangenming
Copy link
Contributor

@zhangenming zhangenming commented Jun 6, 2025

This scene was discovered when I temporarily wanted to debug some information
current i have to

<script setup lang="ts">
const P = Promise.bind(window)
const S = setTimeout.bind(window)
</script>

<template>
  <div @click="async()=>{
   doSomething()
   await new P(r=>S(r, 1000))
   doSomething()
  }">loading</div>
</template>

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Expanded the list of allowed global identifiers to include Promise, setTimeout, and setInterval.

Copy link

coderabbitai bot commented Jun 6, 2025

Walkthrough

The global allow list in the codebase has been updated to include Promise, setTimeout, and setInterval as additional allowed global identifiers. No changes were made to exported or public function declarations.

Changes

File Change Summary
packages/shared/src/globalsAllowList.ts Added Promise, setTimeout, and setInterval to the global allow list string.

Poem

Three new friends join the global crew—
Promise, setTimeout, setInterval too!
Now the list is longer, neat,
More globals allowed, a coder’s treat.
With every hop, our world expands,
As rabbits code with clever hands! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 796c0d6 and dbc9335.

📒 Files selected for processing (1)
  • packages/shared/src/globalsAllowList.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/shared/src/globalsAllowList.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
  • GitHub Check: test / e2e-test
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jun 6, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB (+31 B) 38.4 kB (+14 B) 34.6 kB (-12 B)
vue.global.prod.js 159 kB (+31 B) 58.6 kB (+15 B) 52.1 kB (-64 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.7 kB 18.2 kB 16.7 kB
createApp 54.6 kB 21.3 kB 19.4 kB
createSSRApp 58.9 kB 23 kB 21 kB
defineCustomElement 59.6 kB 22.9 kB 20.9 kB
overall 68.7 kB 26.4 kB 24.1 kB

Copy link

pkg-pr-new bot commented Jun 6, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@13442

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@13442

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@13442

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@13442

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@13442

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@13442

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@13442

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@13442

@vue/shared

npm i https://pkg.pr.new/@vue/shared@13442

vue

npm i https://pkg.pr.new/vue@13442

@vue/compat

npm i https://pkg.pr.new/@vue/compat@13442

commit: dbc9335

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/shared/src/globalsAllowList.ts (1)

3-7: Consider refactoring to an array join for maintainability

Managing a long, multi-line comma-separated string is prone to delimiter mistakes. Converting the list into an array and using .join(',') would improve readability and reduce such errors.

Example:

const GLOBALS_ALLOWED = [
  'Infinity', 'undefined', 'NaN', 'isFinite', 'isNaN',
  'parseFloat', 'parseInt', 'decodeURI', 'decodeURIComponent',
  'encodeURI', 'encodeURIComponent', 'Math', 'Number', 'Date',
  'Array', 'Object', 'Boolean', 'String', 'RegExp',
  'Map', 'Set', 'JSON', 'Intl', 'BigInt',
  'console', 'Error', 'Symbol', 'Promise',
  'setTimeout', 'setInterval'
].join(',');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cdffaf6 and 796c0d6.

📒 Files selected for processing (1)
  • packages/shared/src/globalsAllowList.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: upload
  • GitHub Check: autofix
  • GitHub Check: test / e2e-test
  • GitHub Check: test / lint-and-test-dts
  • GitHub Check: test / unit-test
  • GitHub Check: continuous-release
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@edison1105
Copy link
Member

both setTimeout and setInterval are not standard built-in objects

@absidue
Copy link

absidue commented Jun 7, 2025

Inline handlers are only meant to be used for simple code (https://vuejs.org/guide/essentials/event-handling.html), which is why the list of allowed globals is quite small. The correct approach would be to have function in <script setup> with that code inside of it, which you then reference in the template.

e.g.

<script setup lang="ts">
async function handleClick() {
  doSomething()
  await Promise(r => setTimeout(r, 1000))
  doSomething()
}
</script>

<template>
  <div @click="handleClick">loading</div>
</template>

@zhangenming
Copy link
Contributor Author

both setTimeout and setInterval are not standard built-in objects

console also not list in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
but we add it

@Justineo
Copy link
Member

Justineo commented Jun 9, 2025

See #7939 (comment).

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

Successfully merging this pull request may close these issues.

4 participants